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

Fix mapping #6531

Conversation

davidporter-id-au
Copy link
Member

@davidporter-id-au davidporter-id-au commented Nov 29, 2024

What changed?
Fixes (hopefully) some mapping bugs I introduced with #6523 due to the version history being passed in being nil sometimes, therefore causing panics.

The mapping code as it's currently written panics (and is changed by this PR) which I think is the correct architectural choice. The mappers, by panicing as they presently are, are confusing validation with mapping. This corrects the mapper to gracefully handle nil input, and a quick survey appears to show that there are no expected areas which should never be nil that don't already have nil-check validation in place.

Specifically, in the case of

vh := persistence.NewVersionHistoryItemFromInternalType(token.VersionHistoryItem)
the first request I expect to be empty, but the type mapper presently panics, so addressing that here.

Why?

How did you test it?

  • Unit tests
  • Staging deploy

Potential risks

Release notes

Documentation Changes

@davidporter-id-au
Copy link
Member Author

whoops, got confused and accidentally pushed to the wrong fork, reopening

if input == nil {
panic("version history item is null")
return nil
Copy link
Member

@taylanisikdemir taylanisikdemir Dec 3, 2024

Choose a reason for hiding this comment

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

are callers assuming this function will always return non-nil or panic? If so we should go over them and handle nil case gracefully (potentially by returning a proper error) to avoid nil pointer exceptions downstream

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to do that in the previous PR, though it's certainly possible I missed a few locations. The value I expect to be nil on the first request and subsequently used to keep track of the workflow state.

this case (CDNC-11702) I missed

@davidporter-id-au davidporter-id-au merged commit 5d60abd into cadence-workflow:master Dec 3, 2024
18 checks passed
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.

2 participants