Commit 827592b
fix(api-proxy): fix Gemini API_KEY_INVALID with credential isolation (#1995)
* Initial plan
* fix(api-proxy): fix Gemini API_KEY_INVALID errors
- Add x-goog-api-key to STRIPPED_HEADERS to ensure placeholder is
always stripped before the real key is injected
- Add stripGeminiKeyParam() to remove ?key= query params from URLs
(the @google/genai SDK may append key= in addition to the header)
- Apply stripGeminiKeyParam() in both HTTP and WebSocket Gemini handlers
- Extend auth_inject debug logging to cover x-goog-api-key
- Export shouldStripHeader and stripGeminiKeyParam for unit testing
- Add tests for shouldStripHeader and stripGeminiKeyParam
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/e48bf273-4302-49fe-acde-42cbd46c679c
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* fix: case-insensitive auth header lookup for debug logging
Address PR review feedback:
- Make injected-key detection case-insensitive so auth_inject
debug logs fire for OpenAI/Copilot (which use capital-A
'Authorization') in addition to Anthropic and Gemini.
- Clarify stripGeminiKeyParam guard comments explaining why
absolute/protocol-relative URLs are rejected before parsing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Landon Cox <landon.cox@microsoft.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 16c20a7 commit 827592b
2 files changed
Lines changed: 103 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
170 | 197 | | |
171 | 198 | | |
172 | 199 | | |
| |||
485 | 512 | | |
486 | 513 | | |
487 | 514 | | |
488 | | - | |
| 515 | + | |
| 516 | + | |
489 | 517 | | |
490 | 518 | | |
491 | 519 | | |
| |||
1016 | 1044 | | |
1017 | 1045 | | |
1018 | 1046 | | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
1019 | 1051 | | |
1020 | 1052 | | |
1021 | 1053 | | |
1022 | 1054 | | |
1023 | 1055 | | |
1024 | 1056 | | |
| 1057 | + | |
| 1058 | + | |
1025 | 1059 | | |
1026 | 1060 | | |
1027 | 1061 | | |
| |||
1155 | 1189 | | |
1156 | 1190 | | |
1157 | 1191 | | |
1158 | | - | |
| 1192 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
452 | 518 | | |
453 | 519 | | |
454 | 520 | | |
| |||
0 commit comments