fix: project id forwarding regression (#93)

* fix(proxy): avoid empty project context and hydrate project_id from account token

* test(proxy): add regressions for empty project and token project_id hydration

* test(scripts): add live request validator for project_id forwarding
This commit is contained in:
vin authored and GitHub committed 2026-02-11 12:36:01 +08:00
1 parent 32abbb6793
commit ab78d93252
7 files changed
+534 -13

No files matched your search

+11 -3
View File
@@ -476,17 +476,24 @@ export class ProxyService {
private createGeminiInternalRequest(
model: string,
request: GeminiRequest,
projectId: string,
projectId: string | undefined,
requestType: string,
): GeminiInternalRequest {
return {
project: projectId,
const normalizedProjectId = projectId?.trim();
const internalRequest: GeminiInternalRequest = {
requestId: uuidv4(),
request: this.toInternalGeminiRequest(request),
model,
userAgent: process.env.PROXY_REQUEST_USER_AGENT ?? this.defaultRequestUserAgent,
requestType,
};
if (normalizedProjectId) {
internalRequest.project = normalizedProjectId;
}
return internalRequest;
}
private normalizeGeminiGenerateResponse(response: GeminiResponse): GeminiResponse {
@@ -1481,6 +1488,7 @@ export class ProxyService {
private isProjectNotFoundError(errorMessage: string): boolean {
const msg = errorMessage.toLowerCase();
return (
msg.includes('invalid project resource name projects/') ||
(msg.includes('resource projects/') && msg.includes('could not be found')) ||
(msg.includes('project') && msg.includes('not found'))
);