fix(codegen/hetzner): make create-only required fields optional in global args (swamp-club #2642) #356
Loading…
Reference in a new issue
No description provided.
Delete branch "2642"
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 #2642.
Problem
Generated Hetzner models marked every field that the create (POST) request requires as required in
GlobalArgsSchema. swamp checks that schema in full in two places:swamp model createwith any--global-arg;swamp workflow validate, for steps that name a model type rather than a definition.So a model set up for
get,lookuporlistwas rejected unless callers passed placeholder create values. For example,@swamp/hetzner-cloud/serverswith onlynamefailed withserver_typeandimagemissing.Method runs validate global args with
.partial(), so the read methods themselves already worked. The real failures are the two commands above, the same as for Cloudflare (#2645).Fix (Hetzner codegen only; mirrors the Cloudflare fix, PR 344)
codegen/hetzner/pipeline.ts): the POST body's required list becomescreateRequiredProperties, limited to the body's own properties (Object.hasOwn)..optional()inGlobalArgsSchema. The syntheticnamestays required.createthrowscreate requires global arguments: <names>(sorted) before any API call, including the token check.undefined,nulland""count as missing.servers.name), nothing is ever stored under thecurrentfallback, because create requires it andget/list/lookup/adoptstore under the real name. Soupdate,syncand the action methods throw<method> requires global argument: <field>when it is unset, instead of a misleadingNo data found. Resources whose naming field create doesn't require (floating_ips) keep thecurrentfallback.updateis unchanged, unlike Cloudflare.codegen/designs/hetzner.md): documents the rule and its trade-offs, and removes the incorrect claim that swamp does not enforce required global arguments.Models
pricing(synthetic name) and the read-only models do not.2026.09.29.1) and an identity upgrade entry;manifest.yamlbumps once. The later regeneration commits start from main's model state, so they add only the check lines, with no extra version bumps.generate:hetznerrun produces no changes. The schema had no drift, so there is no separate baseline commit.Behaviour changes to be aware of
swamp workflow validateandswamp model createno longer catch a definition meant forcreatethat is missing a create-required field. The error appears whencreateruns, still before any API call.swamp model type describeno longer marks those fields as required.update,syncand actions on a definition without a create-required naming field fail with<method> requires global argument: <field>.Testing
serversinupdate/syncand not for an optional-name resource or a synthetic one. Snapshots updated; the snapshot diff is only these lines.codegen/hetzner/integration_test.ts(new,Deno.servemock with a fetch redirect):nameandtokenparses;createmissing fields, or with an empty field, fails with zero requests (including the/locationstoken check);updatewithoutnamefails with the new message and no request;getworks with only the token, and a fullcreatePOSTs the fields.It fails against the pre-fix generator.
model createfor servers with onlynamesucceeds (it failed on main);workflow validatestep with agetfails on main withMissing required inputs: server_type, imageand passes on this branch;createfails withcreate requires global arguments: image, server_type;updatewithoutnamefails withupdate requires global argument: name.73d779bc7.Changes after the plan's conformance review
Earlier verification rounds raised low review findings that were fixed on this branch: the create check treats
nulland""as missing;Object.hasOwnin the pipeline filter; safer integration-test setup and teardown; the naming-field check; design-doc trade-off notes. The lifecycle can only return fromverifyingby recording a failed verification, so these are listed here rather than in the conformance record.Known limitations (low review findings)
updateruns the naming-field check in a test;syncand the four actions are covered by checks on the generated code. All six use the same generator helper.No schema changesalthough fields became optional. That text comes from the shared upgrade generator (codegen/shared/upgradesGenerator.ts), the same as for Cloudflare, and the identity upgrade is correct because the schema only got looser.🤖 Generated with Claude Code