Skip to content

fix: reject malformed share ids, drop Content-Length on proxy rewrite… - #571

Open
GoodnessJohn wants to merge 1 commit into
Zenith-options:mainfrom
GoodnessJohn:fix/531-532-533-534-api-route-fixes
Open

GoodnessJohn wants to merge 1 commit into
Zenith-options:mainfrom
GoodnessJohn:fix/531-532-533-534-api-route-fixes

Conversation

@GoodnessJohn

Copy link
Copy Markdown
Contributor

…, fix Sentry tunnel 200-on-failure, surface BFF session upstream errors

closes #531: strip trailing slashes from share id query param and reject any id containing characters outside [A-Za-z0-9_.-] with 400 before crypto verification runs (src/app/api/og/trade/route.tsx)

closes #532: explicitly delete content-length from the upstream request headers in proxy() so a rewritten body never causes the backend to read a truncated or padded payload; the runtime derives the correct length from the actual body (src/lib/bff/handlers.ts)

closes #533: implement the Sentry envelope tunnel route that was missing. Returns 502 when the upstream ingest call fails or returns non-2xx so the SDK can retry; returns 200 only on success. Restricts forwarding to *.sentry.io hosts. Never logs the envelope body (src/app/api/sentry-tunnel/route.ts)

closes #534: rewrite getSession to distinguish three failure modes: network unreachable → 502 { error, upstreamStatus: null }; backend non-2xx (excluding 401) → 502 { error, upstreamStatus }; backend 401 → clear cookie and return unauthenticated 200; backend 2xx → session info 200 (src/lib/bff/handlers.ts)

Summary

Changes

Testing

Checklist

  • Tests pass locally
  • No new warnings/lints introduced

…, fix Sentry tunnel 200-on-failure, surface BFF session upstream errors

- Zenith-options#531: strip trailing slashes from share id query param and reject any id
  containing characters outside [A-Za-z0-9_.-] with 400 before crypto
  verification runs (src/app/api/og/trade/route.tsx)

- Zenith-options#532: explicitly delete content-length from the upstream request headers
  in proxy() so a rewritten body never causes the backend to read a
  truncated or padded payload; the runtime derives the correct length from
  the actual body (src/lib/bff/handlers.ts)

- Zenith-options#533: implement the Sentry envelope tunnel route that was missing.
  Returns 502 when the upstream ingest call fails or returns non-2xx so
  the SDK can retry; returns 200 only on success. Restricts forwarding to
  *.sentry.io hosts. Never logs the envelope body
  (src/app/api/sentry-tunnel/route.ts)

- Zenith-options#534: rewrite getSession to distinguish three failure modes: network
  unreachable → 502 { error, upstreamStatus: null }; backend non-2xx
  (excluding 401) → 502 { error, upstreamStatus }; backend 401 → clear
  cookie and return unauthenticated 200; backend 2xx → session info 200
  (src/lib/bff/handlers.ts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant