Repository navigation
chore(riexchange): require the exchange region in openapi.yaml - #1511
Conversation
The execute request schema listed ri_ids, targets and max_payment_due_usd as required but not region, although validateExecuteExchangeBody rejects an execute without a region with 400. The quote response schema was a bare object, so the Region it always returns (and that execute must be sent back) was undocumented. Execute now lists region as required and documents it; the quote 200 response documents Region as always present. A spec test ties both to the handler: it checks the 400 for a missing region, derives the field names from the Go json tags, and fails if either schema drops them. The two handler comments that retold the history of LeanerCloud#238 now state only the constraint. The TypeScript side was done in LeanerCloud#1350. Closes LeanerCloud#363 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 3 billable files and costs up to $0.75. Or wait 59 minutes for your next included review. View limit details
Comment |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rF5. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rF7. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
VERDICT: APPROVE 9c8457a Findings:
Field-by-field check against the handlers:
Frontend:
Attacked:
|
|
Local verification at |
|
Merged by IAmJSD's agent at IAmJSD's request (IAmJSD is acting owner while the maintainers are away), under the bar IAmJSD set: 3 approving independent review(s) on |
|
Independent review 2 (claude-fleet, cold): APPROVE 9c8457a Findings:
Attacked:
Verified locally (GOTOOLCHAIN=go1.26.10, AWS config files set to /dev/null, cloud env unset):
Reviewed by an independent agent with no author context (second reviewer). Review only: nothing was pushed, and the GitHub review state is unchanged. |
The openapi spec did not match the handler on the RI exchange region.
POST /api/ri-exchange/executelistedrequired: [ri_ids, targets, max_payment_due_usd]withoutregion, butvalidateExecuteExchangeBodyrejects an execute without a region with 400. The quote response was a baretype: object, so theRegionit always returns (and that callers must send back on execute) was not documented. This PR fixes both and adds a test that keeps the spec in step with the handler. It also trims the two handler comments that retold the history of #238.Closes #363
How each item of #363 is now covered
ExchangeQuoteSummary.Region,ExchangeExecuteRequest.regionrequired, call sites fixed, type-level regression test): done in chore(riexchange): make the exchange region required in the TS types #1350.regionas required and documents it. The quote 200 response documentsRegionas a required string that must be sent back asregionon execute.riexchange.tscomment the issue named was already gone on main; the remaining one was intypes.ts). This PR trims the two ininternal/api/handler_ri_exchange.go: the one ingetExchangeQuote(it was at lines 1725-1730 when the issue was filed) and theExchangeQuoteResponsetype comment. Both now state only the constraint. No#238history comment remains in non-test frontend or backend code (grep -rn "#238" frontend/src internal/returns only test files).What changed
internal/api/openapi.yaml: addedregionto the execute request'srequiredlist, with aregionproperty (string) and a description. Addedrequired: [Region]and aRegionproperty to the quote 200 response schema. Both schemas stay open objects, so the other quote fields, which are still undocumented, remain valid.internal/api/handler_ri_exchange.go: comment-only changes. No behavior change.internal/api/openapi_ri_exchange_region_test.go(TestOpenAPIRIExchangeRegionRequired):validateExecuteExchangeBodyreturns 400 "region is required" for an otherwise valid body with no region;ExchangeExecuteRequestBodyandExchangeQuoteResponse), not from hand-copied strings;region, and that the quote 200 schema requires and documentsRegionand tells callers to send it on execute.Why this approach
This is a spec-only change plus a guard test, in the same style as the existing
openapi_*_test.gochecks (yaml.v3 over the embeddedopenapiSpec). Taking the key names from the json tags means a renamed tag fails the test, so the spec cannot drift from the handler without anyone noticing. The quote request'sregionstays optional, as it is in the handler, which defaults it from the SDK chain.Verification
Unit and spec-fixture evidence on this branch (head
9c8457a5, on main3bfc2fe5):openapi.yamlchange stashed,go test ./internal/api/ -count=1 -run TestOpenAPIRIExchangeRegionRequiredFAILS with[]string{"ri_ids", "targets", "max_payment_due_usd"} does not contain "region"/execute must document the region property.required: [Region]from the quote response makes it fail withquote response must list Region as always present.go test ./internal/api/ -count=1: ok.go test ./internal/mocks/ -count=1: ok.go build ./...,go vet ./...,go vet -tags integration ./...: clean.golangci-lint run --allow-parallel-runners ./internal/api/(v2.10.1): 0 issues.gocyclo -over 10 -ignore "_test\.go" internal/api/handler_ri_exchange.go: no output.check-yamland the Go spec tests). As an extra check,npx @redocly/cli@2.71.1 lint internal/api/openapi.yamlreports "Your API description is valid" with the same 42 warnings as on main (warning counts by rule are identical before and after; no new findings).Combined-tree verification at local queue commit
2be43e1e= origin/mainb9271e88+fix/issue-363-next,fix/issue-177-next,fix/issue-919-next,fix/issue-313-next,fix/issue-532-nextandfix/issue-316-nextmerged in that order. Passed:go build ./...;go vetwith and without-tags integration;go test -race -short -count=1 ./...; golangci-lint v2.10.1 with and without the integration tag; gocyclo -over 10;go test -race -tags integrationoninternal/api,internal/auth,internal/config,internal/database/postgres/migrations,internal/purchase,internal/serverandinternal/testutil; the git-secrets scan andscripts/test-git-secrets-allowlist.sh.Out of scope (noted, not changed)
targetsas required, but the handler also accepts the legacytarget_offering_id+target_countform with notargets. Same for the quote request. If the legacy form is still supported, the spec should document it (for example withoneOf). That was not part of chore(riexchange): make exchange region required in TS types and openapi (follow-up to #355) #363, so it is left alone here.Region, the quote response's fields (the promotedExchangeQuoteSummaryfields) are still undocumented in the spec.Maintainer: please mirror the issue's triage labels on this PR:
type/chore,triaged,priority/p3,severity/low,urgency/this-quarter,impact/few,effort/xs.🤖 Generated with Claude Code