Repository navigation
fix: Correct repo vulnerability alert logic - #3144
Merged
stevehipwell merged 1 commit intoFeb 3, 2026
Merged
Conversation
|
👋 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 |
deiga
approved these changes
Jan 30, 2026
3 of 5 tasks
nickfloyd
approved these changes
Feb 3, 2026
Signed-off-by: Steve Hipwell <[email protected]>
stevehipwell
force-pushed
the
fix-repo-vulnerability-alerts
branch
from
February 3, 2026 13:48
8693117 to
c92ee2b
Compare
stevehipwell
enabled auto-merge (squash)
February 3, 2026 13:49
1 task done
JiayangZhou
pushed a commit
to JiayangZhou/terraform-provider-github
that referenced
this pull request
Apr 16, 2026
Signed-off-by: Steve Hipwell <[email protected]>
th7
added a commit
to th7/terraform-provider-github
that referenced
this pull request
Aug 1, 2026
GitHub omits merge-related settings from the repository object unless the caller has push or admin access: "To view merge-related settings, you must have the contents:read and contents:write permissions." It omits fields for archived repositories too. Read through a Get* accessor, an omitted field yields the zero value, which is indistinguishable from the field genuinely being false or empty. Writing that to state produces a diff on every plan that no apply can resolve, because the value an apply would write back is not readable either. Setting only what the response actually contained leaves prior state in place instead. That is what the archived special-case was reaching for; a presence check covers both causes, so the branch is gone, and with it the TODO questioning whether those fields really are omitted for archived repositories. integrations#3144 took the same approach for vulnerability_alerts and security_and_analysis. The cost is that drift in those fields goes undetected while the token cannot read them, which is preferable to a permanent diff no apply can clear. Verified with a scoped installation token holding administration:read and contents:read against a configuration managing nine repositories: every one reported the diff on every plan before, none do after. Reverting to the released provider reproduces it, so the binary is the only variable. Refs integrations#3382
th7
added a commit
to th7/terraform-provider-github
that referenced
this pull request
Aug 8, 2026
GitHub omits merge-related settings from the repository object unless the caller has push or admin access: "To view merge-related settings, you must have the contents:read and contents:write permissions." Read through a Get* accessor, an omitted field yields the zero value, which is indistinguishable from the field genuinely being false or empty. Writing that to state produces a diff on every plan that no apply can resolve, because the value an apply would write back is not readable either. Setting only what the response actually contained leaves prior state in place instead. integrations#3144 took this approach for vulnerability_alerts and security_and_analysis, keying off the presence of security_and_analysis in the response and deprecating ignore_vulnerability_alerts_during_read as "ignored as the provider now handles lack of permissions automatically". setIfPresent extends the same treatment to the merge-related fields, and sits in util.go next to resourceKeysGetOk because the bug class is not repository-specific. The archived special-case is deliberately left in place. It may be redundant — the TODO added alongside integrations#3144 doubts that GitHub omits these fields for archived repositories at all — but that is unverified, and removing it would be a second, untested behaviour change on top of this one. The cost is that drift in these fields goes undetected while the token cannot read them, which is preferable to a permanent diff no apply can clear. Verified with a scoped installation token holding administration:read and contents:read against a configuration managing nine repositories: every one reported the diff on every plan before, none do after. Reverting to the released provider reproduces it, so the binary is the only variable. Refs integrations#3382
th7
added a commit
to th7/terraform-provider-github
that referenced
this pull request
Aug 8, 2026
GitHub omits merge-related settings from the repository object unless the caller has push or admin access: "To view merge-related settings, you must have the contents:read and contents:write permissions." Read through a Get* accessor, an omitted field yields the zero value, which is indistinguishable from the field genuinely being false or empty. Writing that to state produces a diff on every plan that no apply can resolve, because the value an apply would write back is not readable either. Setting only what the response actually contained leaves prior state in place instead. integrations#3144 took this approach for vulnerability_alerts and security_and_analysis, keying off the presence of security_and_analysis in the response and deprecating ignore_vulnerability_alerts_during_read as "ignored as the provider now handles lack of permissions automatically". setIfPresent extends the same treatment to the merge-related fields, and sits in util.go next to resourceKeysGetOk because the bug class is not repository-specific. Skipping a field silently would hide the trade-off, so the read logs one tflog.Warn per repository naming the fields it could not read. integrations#3553 uses the same signal for archived and deleted repositories. A user-facing warning diagnostic would fire on every plan for a token that is permanently read-only, which is noise rather than information. The archived special-case is deliberately left in place. It may be redundant — the TODO added alongside integrations#3144 doubts that GitHub omits these fields for archived repositories at all — but that is unverified, and removing it would be a second, untested behaviour change on top of this one. The cost is that drift in these fields goes undetected while the token cannot read them, which is preferable to a permanent diff no apply can clear. Verified with a scoped installation token holding administration:read and contents:read against a configuration managing nine repositories: every one reported the diff on every plan before, none do after. Reverting to the released provider reproduces it, so the binary is the only variable. Refs integrations#3382
3 of 5 tasks
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.
Corrects logic in #3127
Before the change?
github_repositorywould call vulnerability alerts endpoint on every modificationgithub_repositoryusedignore_vulnerability_alerts_during_readto allow unprivileged users to skip calling the vulnerability alerts endpointAfter the change?
github_repositoryonly calls vulnerability alerts endpoint when requiredgithub_repositoryonly calls vulnerability alerts endpoint during read if the repo response show that the user has the correct permissionPull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!