fix(codegen/gcp): read path params from where the resource keeps them (swamp-club #2669) #464
Loading…
Reference in a new issue
No description provided.
Delete branch "2669"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes swamp-club #2669.
Problem
Generated GCP
updatemethods read the resource id back out of stored state from a field guessed from the path parameter's name. When no mapping matched, they fell back toname, and there was no fallback to globalArgs. BigQuery datasets have nonamefield: the id is indatasetReference.datasetId. So@swamp/gcp/bigquery/datasetsupdatealways failed withMissing required path parameter: datasetId. The same flaw affected every resource whose id lives somewhere other thanname.Fix (codegen/gcp)
resolveStateIdentifierPaths(pipeline.ts) works out where each path parameter lives in the raw GET response and stores it asstateIdentifierPaths. Lookup order:name, when the identifier is described as "Name of…" / "The name of…"id, when it is described as an "ID"*Referenceobject<singular>Id, thenname, thenidOnly the resource's own GET (or update/patch/delete) defines the identifier. A collection-level action ending in
{region}or{bucket}does not.Generated methods (
extensionModelGenerator.ts):update,syncand action methods read that path, using optional chaining for nested fields. The globalArgs fallback always uses a flat key.updatenow falls back to globalArgs likesyncdoes. When no id is found it throwsNo identifier found in existing state or globalArgsinstead of sending an empty path parameter.Design doc:
codegen/designs/gcp.mddocuments the lookup order.Regenerated models
567 files across 104 GCP services. Each file gets a version bump, the
updatefallback, and, where it was wrong, a corrected id read. Examples:name, which doesn't existdatasetReference,tableReferenceand so onname(the filename)idname(display name)pathsync)nameastypetypeI audited by hand every id read that moved off
name, ontoname, or offid. Compute addresses, compute regional resources, Storage buckets and objects, and compute autoscalers keep their working reads.Not regenerated here: cloudlocationfinder, dataproc, displayvideo, integrations, looker, networksecurity and osconfig. The discovery schemas I fetched for these 7 services have drifted from
main, so I reverted them to keep upstream changes out of this diff. The scheduled regenerate-models job will carry both the drift and this fix. Only dataproc (2 files) and displayvideo (33 files) are affected by the fix.Testing
Unit tests for each resolver rule, including a BigQuery discovery-doc round trip.
Generator tests for the nested reads, the flat globalArgs key, unchanged output for name-keyed resources, and the clear error.
referenceIdentifier_integration_test.ts: runs a generated dataset-shaped model against aDeno.servemock and covers:create → update → syncget → updateupdateafter a delete, using the globalArgs fallbackWith the fix removed, the two scenarios from the issue fail.
Idempotency: a second
generate:gcprun produces zero diff outside the 7 excluded services.Verification:
verify-buildpassed 14/14, including the upgrade path test for every touched published extension.verify-reviewspassed (code-review and adversarial-review). Attestation8015cc67-fbed-4b81-b272-aa4d446fada5.🤖 Generated with Claude Code