Skip to content

fix: a created resource answers with what names it - #117

Merged
ShocOne merged 1 commit into
mainfrom
fix/a-created-resource-answers-with-what-names-it
Aug 25, 2026
Merged

fix: a created resource answers with what names it#117
ShocOne merged 1 commit into
mainfrom
fix/a-created-resource-answers-with-what-names-it

Conversation

@ShocOne

@ShocOne ShocOne commented Aug 25, 2026

Copy link
Copy Markdown
Member

Every generated resource failed at apply. Each fix uncovered the next, which is why they arrive together.

1. The request body carried invented values

Fixture derivation read enum, advisory values and format — never the document's own example, which is the only thing a document says about a string whose shape it otherwise leaves to prose. A URL property declaring no format became "tfpfgen-test-stream-endpoint-url", and the API refused it.

- stream_endpoint_url = "tfpfgen-test-stream-endpoint-url"
+ stream_endpoint_url = "https://api.thousandeyes.otel-collector"

The example now wins over an invented name, and a number moves inside whatever bounds the document declares rather than always being 7.

One synthesised name is restored when preferring examples would otherwise leave an entity with no prefixed string at all — the audit's cleanup pass matches a live object by any one of its string fields carrying the prefix, so one is enough, and an entity whose every string is an example is indistinguishable from an object the toolkit did not create.

2. A wire fixture whose example carries a backtick

The generated const is a raw Go literal, which has no escape for one, so the file stopped being Go mid-value:

"suggestion": "The pattern ` / ` will never match anything, did you mean ` * ` instead?",

Latent until now — an invented tfpfgen-test- name can't contain a backtick. The literal is rendered in Go (raw where the value permits, interpreted where it does not) and the template embeds one finished expression.

3. No resource wrote its identity

With bodies the API accepts, creates began succeeding and failing later. The framework refuses a resource that declares an identity schema and returns without setting the identity, reporting it as a provider fault whatever the API did.

34  resources declare an IdentitySchema
 0  resources ever write resp.Identity

Create and Read now write it beside the state.

4. A create response of its own type was discarded whole

CreateMapsResponse required the create response type to be identical to the read model; where they differ the whole response was dropped, including the server-assigned id, so the settling read addressed the object by an empty string. The id is now taken from that response where the same accessor answers the same type on both — which is what makes the conversion settled for the read correct for it. Five resources; conversions are per-type, including APIToFrameworkUUID.

Why one PR

These four share render_resource.go and the crud template. Splitting them there would mean staging half a file.

Verified

make check green at 91.1%. Both pilot trees regenerate and pass postcheck (go mod tidy, go build, go vet): 1,931 files and 4,442 files.

🤖 Generated with Claude Code

Every generated resource failed at apply, and each fix uncovered the next.

The request body carried invented values. Fixture derivation read enum,
advisory values and format, and never the document's own example — the only
thing a document says about a string whose shape it otherwise leaves to
prose. A URL property declaring no format became "tfpfgen-test-endpoint-url"
and the API refused it. The example now wins over an invented name, and a
number moves inside whatever bounds the document declares rather than always
being 7. One synthesised name is restored when preferring examples would
otherwise leave an entity with no prefixed string, because cleanup matches a
live object by that prefix and one is enough.

That reached a wire fixture whose example carries a backtick, which a raw
Go literal has no escape for, so the generated file stopped being Go at that
character. The literal is now rendered in Go — raw where the value permits,
interpreted where it does not — and the template embeds one finished
expression.

With bodies the API accepts, creates began succeeding and failing later: the
framework refuses a resource that declares an identity schema and returns
without setting the identity. Thirty-four declared one and none wrote it.
Create and Read now write it beside the state.

A create whose response is a type of its own was discarded whole, so the
settling read addressed the object by an empty string. The id is taken from
that response where the same accessor answers the same type on both, which
is what makes the read's conversion right for it.

Four changes rather than four commits: they share render_resource.go and the
crud template, and splitting them there would mean staging half a file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ShocOne
ShocOne merged commit b0ab8f5 into main Aug 25, 2026
2 checks passed
@ShocOne
ShocOne deleted the fix/a-created-resource-answers-with-what-names-it branch August 25, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant