Skip to content

fix(aibridge/keypool): reuse request bodies during key failover - #29721

Merged
pawbana merged 1 commit into
mainfrom
pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-4
Sep 28, 2026
Merged

pawbana merged 1 commit into
mainfrom
pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-4

Conversation

@pawbana

@pawbana pawbana commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Prepares key failover for the AI Gateway reverse proxy, which buffers the request body before forwarding.

  • Replay the body through Request.GetBody when set, so a caller that already buffered it avoids a second copy. Without GetBody, the body is still buffered once.
  • Prepare the body before taking a key, so the failover-attempts metric counts only requests actually sent. The unsent body is closed when the pool is exhausted.
  • Drop the per-attempt request clone. The only per-attempt change is the auth header, which InjectAuthKey overwrites.
  • Add a test that the original body is read once across failover attempts.

Generated by Coder Agents on behalf of @pawbana.

@linear-code

linear-code Bot commented Sep 22, 2026

Copy link
Copy Markdown

AIGOV-615

@pawbana pawbana removed their assignment Sep 22, 2026
@pawbana
pawbana added this pull request to stack #29736 September 22, 2026 16:14
@pawbana
pawbana force-pushed the pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-3 branch 7 times, most recently from 5f56ab9 to 06bbc31 Compare September 23, 2026 15:29
@pawbana
pawbana force-pushed the pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-4 branch from 759477c to f080c83 Compare September 23, 2026 15:33
@pawbana
pawbana force-pushed the pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-3 branch from 06bbc31 to b5d6fb5 Compare September 24, 2026 11:53
@pawbana
pawbana force-pushed the pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-4 branch 6 times, most recently from 793c924 to 90b24cd Compare September 24, 2026 17:11
@pawbana
pawbana marked this pull request as ready for review September 24, 2026 17:22
@pawbana
pawbana removed this pull request from stack #29736 September 24, 2026 17:36
@pawbana
pawbana force-pushed the pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-4 branch from 90b24cd to 73f26e0 Compare September 28, 2026 11:04
@pawbana
pawbana changed the base branch from pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-3 to main September 28, 2026 11:05
@pawbana
pawbana requested review from johnstcn and removed request for DanielleMaywood, jdomeracki-coder, johnstcn and spikecurtis September 28, 2026 11:07
Comment thread aibridge/keypool/failover.go Resolved
@pawbana
pawbana enabled auto-merge (squash) September 28, 2026 14:26
@pawbana
pawbana disabled auto-merge September 28, 2026 17:34
@pawbana
pawbana enabled auto-merge (squash) September 28, 2026 17:53
@pawbana
pawbana force-pushed the pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-4 branch from 73f26e0 to c2aef4d Compare September 28, 2026 17:59
@pawbana
pawbana merged commit c5a58b1 into main Sep 28, 2026
29 checks passed
@pawbana
pawbana deleted the pawel/aigov-615-reverse-proxy-handler-with-recorder-lifecycle-and-key-4 branch September 28, 2026 18:16
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants