refactor!: Rename DependencyGraphSnapshot to CreateDependencyGraphSnapshotRequest and pass by value - #4519
Open
JamBalaya56562 wants to merge 3 commits into
Conversation
Match the repository's initialism convention and drop the structfield allowlist entry that tracked it. BREAKING CHANGE: `DependencyGraphSnapshot.Sha` is renamed to `SHA`. Updates google#3644.
…SnapshotRequest` and pass by value The snapshot schema marks version, sha, ref, job, detector, and scanned as required, and its job, detector, and manifest objects have required fields of their own, yet the Go types modelled all of them as optional pointers. Make those fields non-pointer, pass the request body by value in DependencyGraphService.CreateSnapshot, rename the body type to follow the Create...Request convention, and drop DependencyGraphSnapshot from the paramcheck allowlist. BREAKING CHANGE: `DependencyGraphSnapshot` is renamed to `CreateDependencyGraphSnapshotRequest`, `DependencyGraphService.CreateSnapshot` takes it by value, and the fields the API requires (`SHA`, `Ref`, `Job`, `Detector`, `Scanned`; `DependencyGraphSnapshotJob.ID` and `Correlator`; `DependencyGraphSnapshotDetector.Name`, `Version`, and `URL`; `DependencyGraphSnapshotManifest.Name`) are no longer pointers. Updates google#3644.
…hema` The annotation is a plain comment until the check-schema-fields command from google#4375 lands, after which it lets the tool verify this request body against the snapshot schema.
gmlewis
approved these changes
Sep 4, 2026
gmlewis
left a comment
Collaborator
There was a problem hiding this comment.
Thank you, @JamBalaya56562!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4519 +/- ##
=======================================
Coverage 98.53% 98.53%
=======================================
Files 195 195
Lines 17795 17795
=======================================
Hits 17534 17534
Misses 261 261 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Continues the request-body-by-value work in #3644 with
DependencyGraphService.CreateSnapshot, whose body is the dependency submission snapshot document.Why this one
The snapshot schema marks six of its eight properties as required, and its nested objects have required fields of their own, yet the Go types modelled all of them as optional pointers. This is the request-body type that the
check-schema-fieldstool proposed in #4375 flagged first, so this PR fixes the real finding rather than only flipping a parameter:snapshotversionVersion intsha,ref*string,omitemptystringjob,detector*DependencyGraphSnapshotJob,omitempty/*DependencyGraphSnapshotDetector,omitemptyscanned*Timestamp,omitemptyTimestampmetadata,manifests(optional)omitemptyjobid,correlator*string,omitemptystring(html_urlstays optional)detectorname,version,url*string,omitemptystringmanifestname*string,omitemptystring(file,metadata,resolvedstay optional)Value-typed nested structs follow
CreateHostedRunnerRequest.Image HostedRunnerImage(#4371).Scanned Timestampis the first required timestamp in an exported request type; it uses a barejson:"scanned"tag since the API requires it on every submission.Commits
refactor!:Sha→SHA— the field was on thestructfieldallowlist as a TODO; since the type is changing incompatibly anyway, this clears that entry.refactor!:rename + pass by value —DependencyGraphSnapshotbecomesCreateDependencyGraphSnapshotRequest(theCreate…Requestconvention used by the rest of the series; theDependencyGraphSnapshot*sub-types keep their names as parts of the snapshot document),CreateSnapshottakes it by value, the required fields above become non-pointer, andDependencyGraphSnapshotis removed from theparamcheckallowlist. The docs operation name ("Create a snapshot…") already matches the method verb, so no method rename.docs://meta:schemaannotation — a plain comment until feat: Add acheck-schema-fieldscommand to the metadata tool #4375 lands, after whichcheck-schema-fieldsvalidates this body automatically. Running the tool from that branch against this PR reportsFound 0 schema field issues/Checked 1 annotations on 1 annotated structs— before this change the same type produced five required-but-pointer findings.BREAKING CHANGE:
DependencyGraphSnapshotis renamed toCreateDependencyGraphSnapshotRequest, itsShafield toSHA,DependencyGraphService.CreateSnapshottakes it by value, and the fields the API requires (SHA,Ref,Job,Detector,Scanned;DependencyGraphSnapshotJob.IDandCorrelator;DependencyGraphSnapshotDetector.Name,Version, andURL;DependencyGraphSnapshotManifest.Name) are no longer pointers.Verified with
go build ./...,gofmt,go vet -tags integration ./test/integration/, the full./github/test suite (CreateSnapshotat 100% coverage), generator idempotency, andcustom-gcl(0 issues with the allowlist entries removed). No usages outside thegithubpackage.Updates #3644.
cc @jvm986