fix: support in-place updates for repository custom property values#3378
Open
milan-dewilde wants to merge 1 commit intointegrations:mainfrom
Open
fix: support in-place updates for repository custom property values#3378milan-dewilde wants to merge 1 commit intointegrations:mainfrom
milan-dewilde wants to merge 1 commit intointegrations:mainfrom
Conversation
The github_repository_custom_property resource declared property_value as ForceNew with no Update function, causing every value change to plan as a destroy+create. The destroy step calls the upsert API with a nil value, which unsets the property on GitHub before the create step rewrites it. Wire an Update function that calls the same upsert as Create, and remove ForceNew from property_value. Identity fields (repository, property_name, property_type) remain ForceNew.
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
This file contains hidden or 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
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.
Resolves #3377
Before the change?
property_valueongithub_repository_custom_propertyproduces a-/+ destroy and then create replacementplan, becauseproperty_valueis declaredForceNew: trueand the resource has noUpdatefunction (onlyCreate,Read,Delete).client.Repositories.CreateOrUpdateCustomPropertieswithValue: nil, which per the GitHub REST docs "removes or 'unsets' the property value". The subsequent create step re-sets it, leaving a window where the property is unset (or reverts to the org-level default) which is breaking downstream systems that depend on the property being continuously set.PATCH /repos/{owner}/{repo}/properties/values) is documented as upsert, andCreatealready calls it. The sibling resourcegithub_organization_custom_propertyis wired withCreate + Read + Update + Deletefor the analogous org-level API; the repo-level resource is the outlier.After the change?
Updatefunction that delegates toCreate, mirroring the pattern used bygithub_organization_custom_properties.ForceNew: truefrom theproperty_valueschema entry. Identity fields (repository,property_name,property_type) remainForceNew— those are immutable on the GitHub API side.updates custom property value in place without replacement) that applies an initial value, updates it, asserts the resource ID is unchanged across the two steps (proving no replacement), and asserts an empty follow-up plan.~ update in-placeand issues a single upsert, with no intermediate unset window.Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!