Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update compatibility adapter to support new enum value #1337

Merged
merged 2 commits into from
May 20, 2024
Merged

Update compatibility adapter to support new enum value #1337

merged 2 commits into from
May 20, 2024

Conversation

Shaddoll
Copy link
Contributor

What changed?

  • Update idl version
  • Update compatibility adapter to support new enum value

Why?

How did you test it?
unit tests

Potential risks

Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.20%. Comparing base (fc1d544) to head (1214d55).

Additional details and impacted files

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc1d544...1214d55. Read the comment docs.

@@ -364,6 +364,8 @@ func CancelExternalWorkflowExecutionFailedCause(t *shared.CancelExternalWorkflow
switch *t {
case shared.CancelExternalWorkflowExecutionFailedCauseUnknownExternalWorkflowExecution:
return apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION
case shared.CancelExternalWorkflowExecutionFailedCauseWorkflowAlreadyCompleted:
return apiv1.CancelExternalWorkflowExecutionFailedCause_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_COMPLETED
}
panic("unexpected enum value")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as part of this PR but we should revisit the idea of panic'ing here. This makes the client not forward-compatible. Especially for the fields that are only used for informational purposes we don't need to be strict like this.
@Groxx WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, I think falling back to a default value is a safe option and it makes sense

Copy link
Contributor

@Groxx Groxx May 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a decent "unknown" value, yea - unknown is probably fine as a fallback. unrecognized is unknown, and should probably be treated the same. it's probably a safe option here, though some kind of "non-fatal err return value" would let us detect it (otherwise this'll be a silent fallback, possibly hiding who knows how many flaws).


the main thing that makes me actually prefer panics is that they tend to reliably fail tests. assert.Error(t, err) will happily ignore return errors.New("impossible: unrecognized enum") despite that being clearly intended to be a "must fail tests" value. they also tend to be auto-categorized as "severe problem, alert oncall" because panics simply shouldn't be happening.

so mistakes tend to be noticed and fixed faster.

they are rather clearly more dangerous... but bad data is often worse, as it's so hard to fix and tends to go unnoticed for a long time.

anyway.

personally I think things like this should be immediately alerted, so we probably need some kind of universally-recognized "this is a flaw that we could not prevent at compile time" marker. historically I've used ProgrammerError(..) types, and hooked them up to always emit a metric when they're returned anywhere. it worked pretty well.

we would need to add those checks and switch to error wrapping (so we don't lose the type) and also exclude them from all assert.Error checks to keep them as identifiable as panics tho.

@Shaddoll Shaddoll merged commit f5ec359 into master May 20, 2024
14 checks passed
@Shaddoll Shaddoll deleted the idl branch May 20, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants