Skip to content

fix(api): /claim/preview emits items envelope alias for resources (B5-P1-3)#209

Merged
mastermanas805 merged 3 commits into
masterfrom
fix/api-claim-preview-items-alias-2026-05-30
May 30, 2026
Merged

fix(api): /claim/preview emits items envelope alias for resources (B5-P1-3)#209
mastermanas805 merged 3 commits into
masterfrom
fix/api-claim-preview-items-alias-2026-05-30

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Summary

  • /claim/preview shipped with envelope field 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) uses items. Agents generated against the OpenAPI snapshot had to special-case this one envelope shape.
  • 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 / existing curl recipes.
  • OpenAPI ClaimPreviewResponse schema marks resources deprecated and routes new clients at items. Snapshot regenerated via `make openapi-snapshot`.
  • B5-P1-3 (BugBash 2026-05-20 master ledger).

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

  • `internal/handlers/onboarding.go` (the bug — both emit sites)
  • `internal/handlers/openapi.go` (ClaimPreviewResponse schema; items canonical, resources deprecated)
  • `openapi.snapshot.json` (regenerated)
  • `internal/handlers/claim_preview_items_alias_test.go` (coverage gate, both branches)

Test plan

  • `go test ./internal/handlers/ -run 'TestClaimPreview' -count=1 -short` → ok
  • `make openapi-snapshot-check` → snapshot matches handlers.OpenAPISpecProduction()
  • CI green
  • After deploy: `curl /claim/preview?t= | jq '.items, .resources'` both non-null

🤖 Generated with Claude Code

mastermanas805 and others added 3 commits May 30, 2026 22:16
… (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>
@mastermanas805 mastermanas805 merged commit 9a66ebd into master May 30, 2026
20 of 21 checks passed
@mastermanas805 mastermanas805 deleted the fix/api-claim-preview-items-alias-2026-05-30 branch May 30, 2026 17:32
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