Skip to content

Commit 06dfc83

Browse files
Copilotlpcox
andauthored
fix: update stale comments and add missing 6th test case
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/46aa116c-47a9-4f66-8e20-13cb6f683aab Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent 314ecfe commit 06dfc83

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

containers/api-proxy/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ if (require.main === module) {
10701070
const contentLength = parseInt(req.headers['content-length'], 10) || 0;
10711071
if (checkRateLimit(req, res, 'gemini', contentLength)) return;
10721072

1073-
// Strip any ?key= query parameter — the @google/genai SDK may append it to the URL.
1073+
// Strip any auth query params (?key=, ?apiKey=, ?api_key=) — the SDK may append them.
10741074
// The proxy injects the real key via x-goog-api-key header instead.
10751075
req.url = stripGeminiKeyParam(req.url);
10761076

@@ -1080,7 +1080,7 @@ if (require.main === module) {
10801080
});
10811081

10821082
geminiServer.on('upgrade', (req, socket, head) => {
1083-
// Strip any ?key= query parameter — the @google/genai SDK may append it to the URL.
1083+
// Strip any auth query params (?key=, ?apiKey=, ?api_key=) — the SDK may append them.
10841084
req.url = stripGeminiKeyParam(req.url);
10851085
proxyWebSocket(req, socket, head, GEMINI_API_TARGET, {
10861086
'x-goog-api-key': GEMINI_API_KEY,

containers/api-proxy/server.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ describe('stripGeminiKeyParam', () => {
564564
expect(stripGeminiKeyParam('/v1/models/gemini-pro:generateContent?key=foo&apiKey=bar&api_key=baz&alt=json'))
565565
.toBe('/v1/models/gemini-pro:generateContent?alt=json');
566566
});
567+
568+
it('should handle path with only api_key= param, leaving no trailing ?', () => {
569+
const result = stripGeminiKeyParam('/v1/generateContent?api_key=abc');
570+
expect(result).toBe('/v1/generateContent');
571+
});
567572
});
568573

569574
// ── Helpers for proxyWebSocket tests ──────────────────────────────────────────

0 commit comments

Comments
 (0)