fix(api): /claim/preview emits items envelope alias for resources (B5-P1-3)#209
Merged
mastermanas805 merged 3 commits intoMay 30, 2026
Merged
Conversation
… (B5-P1-3)
Every list endpoint on the platform (`/api/v1/resources`,
`/api/v1/deployments`, `/api/v1/audit`, `/api/v1/backups`,
`/api/v1/team/invitations`) wraps results in `items` — but
`/claim/preview` shipped with `resources`. Agents generated against
the OpenAPI snapshot had to special-case this one envelope shape, and
the rule-22 contract surface checklist (CLAUDE.md) flagged it as drift.
This PR adds `items` as the canonical alias on both response branches
(already_claimed empty + happy-path with rows) while keeping
`resources` populated as a deprecated legacy alias — no break for the
dashboard, sdk-go, or existing curl recipes. The OpenAPI schema marks
`resources` deprecated and routes new clients at `items`.
Coverage (rule 17, B5-P1-3 / BugBash 2026-05-20):
Symptom: /claim/preview emits `resources`, not `items`
Enumeration: grep -n '"resources":\|"items":' internal/handlers/onboarding.go
Sites found: 2 (already_claimed branch L114, happy path L178)
Sites touched: 2 (both arms emit both keys)
Coverage test: TestClaimPreview_ItemsAlias_AlreadyClaimedBranch +
TestClaimPreview_ItemsAlias_HappyPathBranch — both
assert `items` AND `resources` are present and
equal-length on each branch.
Live verified: Awaiting deploy + `curl /claim/preview?t=<jwt> | jq '.items'`
Rule 22 surface:
- internal/handlers/onboarding.go (the bug)
- internal/handlers/openapi.go (ClaimPreviewResponse schema)
- openapi.snapshot.json (regenerated via `make openapi-snapshot`)
- internal/handlers/claim_preview_items_alias_test.go (coverage gate)
Co-Authored-By: Claude Opus 4.7 (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.
Summary
resources, but every other list endpoint on the platform (/api/v1/resources, /api/v1/deployments, /api/v1/audit, /api/v1/backups, /api/v1/team/invitations) usesitems. Agents generated against the OpenAPI snapshot had to special-case this one envelope shape.itemsas the canonical alias on both response branches (already_claimed empty + happy-path with rows) while keepingresourcespopulated as a deprecated legacy alias. No break for the dashboard / sdk-go / existing curl recipes.resourcesdeprecated and routes new clients atitems. Snapshot regenerated via `make openapi-snapshot`.Coverage block (rule 17)
```
Symptom: /claim/preview emits resources, not items
Enumeration: grep -n '"resources":\|"items":' internal/handlers/onboarding.go
Sites found: 2 (already_claimed branch, happy path)
Sites touched: 2 (both arms emit both keys)
Coverage test: TestClaimPreview_ItemsAlias_AlreadyClaimedBranch +
TestClaimPreview_ItemsAlias_HappyPathBranch — both
assert items AND resources are present and equal-length
on each branch.
Live verified: Awaiting deploy + curl /claim/preview?t= | jq '.items'
```
Rule 22 surface
Test plan
🤖 Generated with Claude Code