Skip to content

refactor!: Rename CodeScanningAlertState and DependabotAlertState to ...Request and pass them by value - #4617

Open
JamBalaya56562 wants to merge 3 commits into
google:masterfrom
JamBalaya56562:refactor/3644-alert-state-request-types
Open

JamBalaya56562 wants to merge 3 commits into
google:masterfrom
JamBalaya56562:refactor/3644-alert-state-request-types

Conversation

@JamBalaya56562

Copy link
Copy Markdown
Contributor

Updates #3644.

BREAKING CHANGE: CodeScanningAlertState and DependabotAlertState are renamed to UpdateCodeScanningAlertRequest and UpdateDependabotAlertRequest and are passed by value to CodeScanningService.UpdateAlert and DependabotService.UpdateAlert; their State fields are now *string.

This PR converts the request body types of the two "update an alert" endpoints. Both request schemas are anyOf: [{required: [state]}, {required: [assignees]}], so state is not always required, and neither Go type had assignees.

Old New Method Endpoint
*CodeScanningAlertState UpdateCodeScanningAlertRequest CodeScanningService.UpdateAlert PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}
*DependabotAlertState UpdateDependabotAlertRequest DependabotService.UpdateAlert PATCH /repos/{owner}/{repo}/dependabot/alerts/{alert_number}

Three commits:

  1. feat - Add the response fields missing from the alert schemas: Alert.Assignees, Alert.DismissalApprovedBy, Alert.LinkedPullRequests, DependabotAlert.Assignees, and DependabotAlert.DismissalRequest (with a new DependabotAlertDismissalRequest type).
  2. feat! - Follow the anyOf request schemas: State becomes *string with omitempty, and both types get Assignees []string with omitzero (an empty slice is sent as [], which the API documents as removing all assignees). Also add create_request (CreateRequest) to the code scanning type and agent_assignment (AgentAssignment, new DependabotAlertAgentAssignment type) to the Dependabot type. testJSONMarshal tests fix the JSON for the state-only, assignees-only, and empty-assignees cases.
  3. refactor! - Rename both types to ...Request and pass them by value. Both entries are removed from body-allowed-pointer-types, and the test variables are named body.

The method names already match the GitHub docs operation names ("Update a code scanning alert", "Update a Dependabot alert"), so no methods are renamed.

Verified locally: go build ./..., go vet -tags integration ./test/integration/, example module build, go test ./..., generated files idempotent, custom-gcl 0 issues, and script/check-schema-fields.sh reports no new issues.

@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.61%. Comparing base (70b9759) to head (ce99aad).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4617   +/-   ##
=======================================
  Coverage   98.61%   98.61%           
=======================================
  Files         199      199           
  Lines       18693    18693           
=======================================
  Hits        18435    18435           
  Misses        258      258           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @JamBalaya56562!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @Not-Dhananjay-Mishra - @jvm986

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants