fix(gateway): surface grants 409 stale-version conflict as typed error instead of id-less success - #183
Open
maciejwitowski wants to merge 1 commit into
Open
fix(gateway): surface grants 409 stale-version conflict as typed error instead of id-less success#183maciejwitowski wants to merge 1 commit into
maciejwitowski wants to merge 1 commit into
Conversation
…bricating id-less success
A grants 409 without a grant id is a stale-grantVersion conflict — the
registration did NOT apply. Returning `{grantId: undefined}` made callers
treat it as success and lose the gateway's `currentGrantVersion` rebase
hint; downstream this terminally failed external-consumer DCRs with the
misleading `missing_external_completion_routing`.
createGrant now keeps the idempotent-replay behavior when the 409 body
carries a grant id, and otherwise throws the exported
`GatewayGrantVersionConflictError` (status 409, `currentGrantVersion`)
so callers can re-sign at currentGrantVersion+1 and retry.
Note for consumers: personal-server-ts should adopt conflict handling
(auto-rebase retry) in the same release that bumps past this version.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
No blocking findings. The change correctly distinguishes idempotent 409s from stale-version conflicts and exports the typed error from browser/node entrypoints. Minor test improvement: assert Tests could not run because dependencies ( |
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.
Problem
createGatewayClient().createGranttreats everyPOST /v1/grants409 as idempotent success. But the gateway has two distinct 409s:grantVersion— body is{success:false, error, currentGrantVersion}with no grant id → the registration did not apply, and the SDK returned{grantId: undefined}, silently discarding thecurrentGrantVersionrebase hint.Downstream impact (traced live on Moksha): the id-less "success" propagates through personal-server-ts (201 with no grantId) into the unity-surfaces DCR client, which terminally fails external-consumer DCRs with the misleading
missing_external_completion_routing("Personal Server routing is not ready yet") — routing was fine. This breaks the one-go builder flow (connect source + grant in one pass). Web-side mitigation: vana-com/unity-surfaces#744.Change
createGrantkeeps idempotent-success only when the 409 body carries a grant id.GatewayGrantVersionConflictError(name,status: 409,currentGrantVersion) with the gateway's error message, so callers can re-sign atcurrentGrantVersion + 1and retry.browserandserverentrypoints.Compatibility
Behavior changes only for the stale-version case, which previously produced a broken success (
grantId: undefined) that no caller could act on. personal-server-ts should adopt conflict handling (auto-rebase retry) in the same release that bumps past this version — follow-up PR incoming.Tests
{currentGrantVersion, no id}→ rejects with typed error carrying the hint.🤖 Generated with Claude Code