-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 resource-ref-as-ID marshaling. #6125
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When marshaling a resource reference as its ID (i.e. when opts.KeepResources is false, as it will be in the case of downlevel SDKs and resource providers), we must take care to marshal/unmarshal an empty ID as the unknown property value. Fixes #5939.
lukehoban
reviewed
Jan 15, 2021
pgavlin
added
the
impact/no-changelog-required
This issue doesn't require a CHANGELOG update
label
Jan 15, 2021
lblackstone
approved these changes
Jan 15, 2021
- Bifurcate resource reference creation into two methods: one for creating references to custom resources and one for creating references to component resources. - Store the ID in a resource reference as a PropertyValue s.t. it can be computed. - Add a helper method for retrieving the ID as a string + an indicator of whether or not the reference has an ID.
lblackstone
approved these changes
Jan 15, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the refactor; much easier to understand
func MakeCustomResourceReference(urn URN, id ID, packageVersion string) PropertyValue { | ||
idProp := NewStringProperty(string(id)) | ||
if id == "" { | ||
idProp = MakeComputed(NewStringProperty("")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
idProp = MakeComputed(NewStringProperty("")) | |
idProp = MakeComputed(idProp) |
Closed
lblackstone
added a commit
that referenced
this pull request
Jan 21, 2021
PR #6125 introduced a bug by marshaling resource ids as PropertyValues, but not handling that case on the unmarshaling side. The previous code assumed that the id was a simple string value. This bug prevents any stack update operations (preview, update, destroy, refresh). Since this change was already released, we must now handle both cases in the unmarshaling code.
stack72
added a commit
that referenced
this pull request
Jan 21, 2021
pgavlin
pushed a commit
that referenced
this pull request
Jan 21, 2021
PR #6125 introduced a bug by marshaling resource ids as PropertyValues, but not handling that case on the unmarshaling side. The previous code assumed that the id was a simple string value. This bug prevents any stack update operations (preview, update, destroy, refresh). Since this change was already released, we must now handle both cases in the unmarshaling code.
lblackstone
added a commit
that referenced
this pull request
Jan 21, 2021
* Fix resource-ref-as-ID marshaling. (#6125) This reapplies 2f0dba2. * Fix malformed resource value bug PR #6125 introduced a bug by marshaling resource ids as PropertyValues, but not handling that case on the unmarshaling side. The previous code assumed that the id was a simple string value. This bug prevents any stack update operations (preview, update, destroy, refresh). Since this change was already released, we must now handle both cases in the unmarshaling code. * Add resource ref unit tests for the Go SDK. (#6142) This reapplies 3d50591. Co-authored-by: Pat Gavlin <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When marshaling a resource reference as its ID (i.e. when
opts.KeepResources is false, as it will be in the case of downlevel SDKs
and resource providers), we must take care to marshal/unmarshal an empty
ID as the unknown property value.
Fixes #5939.