feat: a listed resource declares the identity its list results carry - #100
Merged
Conversation
NewListResult builds every result against the resource's identity and resource schemas, so a list resource whose resource declares no identity panics the moment terraform calls it. No resource declared one. A resource the API can enumerate now does: its addressing attributes and its id, all required for import. Addressing is part of it because the framework requires an identity to name at most one remote object per provider, and an id alone does not where a parent scopes it — two repositories' hooks may share one. The id is a string in the identity whatever the API keys its objects with. An identity names an object and is compared for equality; it is not the state value, and the accessor a list reaches its id through already renders every scalar as a string. Both halves render from one derivation, so the identity a list streams and the identity the resource declares cannot drift. The generated test stands the resource up and reads both schemas off it rather than fabricating one. 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.
Phase 2. #99 made list resources valid at schema-load time; this makes them work
when terraform actually calls them.
The defect
list/list_resource.go:135 NewListResultbuilds every result against twoschemas it reads off the request:
The server sources the identity from
resource.ResourceWithIdentityand returnsnil when the resource does not implement it (
fwserver/server.go:807, "It'svalid for a resource to not have an identity"). No resource declared one, so
every list resource would panic on its first result.
It was invisible because the generated test fabricated its own identity schema
and passed no resource schema at all. One entity proved it — the only list
resource whose SDK call currently succeeds:
What changed
A resource the API can enumerate declares an identity: its addressing
attributes, then its id, all
RequiredForImport.Addressing is part of it because the framework requires an identity to name "at
most one remote object per provider" — an
idalone does not where a parentscopes it, since two repositories' hooks may share one.
The id is a string in the identity whatever the API keys its objects with.
An identity names an object and is compared for equality; it is not the state
value, and
findIdentityNodealready renders every scalar as a string.Both halves render from one derivation (
resourceIdentity), so the identitya list streams and the identity its resource declares cannot drift:
The id comes from the element; every other attribute is addressing, which the
list block's configuration already supplied to make the call. A list block that
cannot supply one the identity names refuses, rather than streaming a partial
identity.
The generated test stands the resource up and reads both schemas off it,
instead of fabricating one — so it now exercises what terraform does.
Only listed resources declare an identity. Identity affects state format and
enables import-by-identity; widening it to every resource is a separate,
deliberate call.
Measured effect
Generated list-resource test failures, before → after:
The panic is gone and
organizations_settings_billing_budgetpasses end to end— an identity round-trips through a real
Listcall for the first time.What remains is almost entirely Phase 3, the fixture defect:
Refusals: github 834 → 835 (+1, a list block that cannot supply an identity
attribute). jamfpro and thousandeyes unchanged.
provider verify— no drift onall three (4384 / 3895 / 1798 files).
Gates
gofmt,repo_hygiene_gate.sh,golangci-lint(0 issues),go build/go vet— passgo test ./...— passprovider generate+provider verifyon all three — no drift🤖 Generated with Claude Code