Skip to content

fix(0089): strip API Gateway stage prefix so /v1 routes resolve (+ complete 0089)#102

Merged
karczuRF merged 1 commit into
developfrom
fix/0089-api-handler-stage-prefix-404
Jul 8, 2026
Merged

fix(0089): strip API Gateway stage prefix so /v1 routes resolve (+ complete 0089)#102
karczuRF merged 1 commit into
developfrom
fix/0089-api-handler-stage-prefix-404

Conversation

@karczuRF

@karczuRF karczuRF commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

The bug (found deploying 0089)

After deploying Prices-production-ApiGateway, every /v1 route returned 404 with a valid API key — /v1/backfill/status, /v1/assets, all of them — while /health returned 200 and a keyless call returned 403.

Root cause: the api-handler Lambda was missing AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH=true, so lambda_http handed axum the path with the API Gateway stage (/production/v1/backfill/status), matching no route → 404 in ~2 ms (no CH call, confirmed in logs).

Why it went unnoticed: /health is a keyless API Gateway mock (never invokes the Lambda), and 0040's tests are all in-process tower::oneshot — this was the first real gateway invocation. It would have 404'd the entire public API in T2, not just /backfill/status.

The fix (config-only, no Rust change)

Add AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH: 'true' to the api-handler environment in compute-stack.ts, mirroring BE's api-handler (BE documents the same var in crates/api/src/common/edge_lock.rs). The Compute redeploy was env-only — diff = one added variable on ApiHandlerFunction, ledger-processor untouched.

Verified live

GET /v1/backfill/status  → 200
{"realtime_tip_ledger":63371525,
 "sdex":{"status":"paused","current_ledger":50457424,"start_ledger":1,"target_ledger":63371525,
         "progress_pct":79.62,"ledgers_remaining":12914101,"last_push_at":"2026-07-07T19:37:03Z"},
 "soroban_amm":{"status":"running","last_push_at":"2026-07-07T19:37:03Z","completed_at":null}}
no-key → 403,  /health → 200

Also completes + archives task 0089 — the M1 AC "GET /backfill/status endpoint live and returning valid progress data" is now satisfied.

M1 after this

Remaining M1: 0088 (backfill run, paused) + 0082 (worker/MV verification). The read API is now live.

The api-handler Lambda was missing AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH,
so lambda_http handed axum the path WITH the /production stage prefix and
every /v1 route 404'd (health masked it — it is a keyless gateway mock;
0040's tests are all in-process tower::oneshot, never through the gateway).
Would have 404'd the entire public API in T2, not just /backfill/status.

Add the env var to the api-handler in compute-stack.ts (mirrors BE's
api-handler; env-only Compute redeploy). GET /v1/backfill/status now
returns 200 + a valid §4.5 BackfillStatus envelope.

Also completes + archives task 0089 (deploy ApiGateway + verify the
endpoint live) — the M1 AC "backfill/status endpoint live and returning
valid progress data" is now satisfied.
@karczuRF karczuRF merged commit 2ff832b into develop Jul 8, 2026
3 checks passed
@karczuRF karczuRF deleted the fix/0089-api-handler-stage-prefix-404 branch July 8, 2026 13:48
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