fix: a created resource answers with what names it - #117
Merged
Conversation
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>
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.
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.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:
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.
Create and Read now write it beside the state.
4. A create response of its own type was discarded whole
CreateMapsResponserequired 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, includingAPIToFrameworkUUID.Why one PR
These four share
render_resource.goand the crud template. Splitting them there would mean staging half a file.Verified
make checkgreen 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