fix(swap-service): pass the BOB Gateway API key through to the swapper - #58
Merged
Conversation
The key was a placeholder empty string, so the BOB SDK omitted the Authorization header and every gateway call was rejected. Validated at 32 characters because the SDK throws on any other length. 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.
Description
getSwapperConfig()passed a placeholder empty string forVITE_BOB_GATEWAY_API_KEY, so the BOB SDK omitted the auth header entirely:Every gateway call therefore went out unauthenticated and came back
403 Forbiddenwith an HTML body, surfacing asGatewayError: Non-JSON response: HTTP 403 Forbiddenin the status poller.This wires the key through
env.tsandgetSwapperConfig(), matching how the other swapper keys are declared, and documents it in.env.example.Validated with
z.string().length(32)rather than.min(1)because the SDK hard-rejects any other length at client construction, where it would surface as an unhandled throw rather than a startup error:VITE_BOB_GATEWAY_API_KEYmust be set in Railway before this merges — it is a required variable, so the service will refuse to start without it.Two config placeholders remain empty and are deliberately out of scope:
VITE_ACROSS_INTEGRATOR_ID(may affect Across affiliate attribution) andVITE_TRON_GRID_API_KEY(Sun.io falls back to TronGrid's public rate limits).Testing
/v3/get-order/{id}return403with a Cloudflare HTML body, matching the observed error signature exactly.src/env.tsdirectly under ts-node to check schema behaviour, since the test suite mocks the env module wholesale and would not catch a bad schema:Invalid environment variables: ... at VITE_BOB_GATEWAY_API_KEYThe key itself could not be verified end to end from a dev machine — Cloudflare blocks that IP for all requests to
gateway-api-mainnet.gobob.xyz, including unauthenticated ones to public endpoints, so the request never reaches the API. Worth watching the first deploy: if BOB swaps still logNon-JSON response: HTTP 403, the block is on the source IP rather than the credential, and BOB would need to allowlist it.🤖 Generated with Claude Code