-
Notifications
You must be signed in to change notification settings - Fork 42
[Refactor] Env.ts and better error message on facilitator proxy failure #668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Add PNPM Knip and Env.ts
…ilure-message specific facilitators failed error
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
🚅 Deployed to the echo-pr-668 environment in echo
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Suggestion:
The code uses process.env.GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED directly instead of accessing it through the centralized env object, and this environment variable is not defined in the env.ts configuration schema.
View Details
📝 Patch Details
diff --git a/packages/app/server/src/env.ts b/packages/app/server/src/env.ts
index 473efd0c..4738d41a 100644
--- a/packages/app/server/src/env.ts
+++ b/packages/app/server/src/env.ts
@@ -47,6 +47,7 @@ export const env = createEnv({
TAVILY_API_KEY: z.string().optional(),
E2B_API_KEY: z.string().optional(),
GOOGLE_SERVICE_ACCOUNT_KEY: z.string().optional(),
+ GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED: z.string().optional(),
// API Keys - Echo
API_KEY_HASH_SECRET: z.string().default('change-this-in-production-very-secret-key'),
diff --git a/packages/app/server/src/providers/VertexAIProvider.ts b/packages/app/server/src/providers/VertexAIProvider.ts
index 3a59994e..fe9b113b 100644
--- a/packages/app/server/src/providers/VertexAIProvider.ts
+++ b/packages/app/server/src/providers/VertexAIProvider.ts
@@ -472,8 +472,7 @@ export class VertexAIProvider extends BaseProvider {
}
private getServiceAccountCredentials(): any {
- const serviceAccountKeyEncoded =
- process.env.GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED;
+ const serviceAccountKeyEncoded = env.GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED;
// decode from base64
const serviceAccountKey = Buffer.from(
serviceAccountKeyEncoded!,
Analysis
VertexAIProvider uses process.env directly instead of centralized env object
What fails: VertexAIProvider.getServiceAccountCredentials() accesses process.env.GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED directly, while all other providers use the centralized env object pattern
How to reproduce:
// When GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED is undefined:
const serviceAccountKeyEncoded = process.env.GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED; // undefined
const result = Buffer.from(serviceAccountKeyEncoded!, 'base64'); // Runtime errorResult: TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
Expected: Should follow the established pattern used by AnthropicGPTProvider, GPTProvider, and others: env.GOOGLE_SERVICE_ACCOUNT_KEY_ENCODED with proper Zod validation
| logMetric('facilitator_proxy_failure', 1, { | ||
| method, | ||
| status: res.status, | ||
| }); | ||
| throw new Error(`Proxy facilitator failed for ${method}: ${errorMsg}`); | ||
| throw new FacilitatorProxyError(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| logMetric('facilitator_proxy_failure', 1, { | |
| method, | |
| status: res.status, | |
| }); | |
| throw new Error(`Proxy facilitator failed for ${method}: ${errorMsg}`); | |
| throw new FacilitatorProxyError(); | |
| const errorBody = await res.text(); | |
| const errorMsg = `${res.status} ${res.statusText} - ${errorBody}`; | |
| logMetric('facilitator_proxy_failure', 1, { | |
| method, | |
| status: res.status, | |
| }); | |
| throw new FacilitatorProxyError(`Proxy facilitator failed for ${method}: ${errorMsg}`); |
The error handling in facilitatorProxy has lost critical debugging information. When a facilitator request fails, the response body and status text are no longer captured or included in the error, making troubleshooting very difficult.
View Details
Analysis
Lost error details in facilitatorProxy error handling
What fails: facilitatorProxy() in facilitatorProxy.ts throws generic FacilitatorProxyError without capturing response body or status text when facilitator requests return non-200 status codes
How to reproduce:
- Trigger a facilitator request that returns non-200 status (e.g., 503 Service Unavailable)
- Current error: "FacilitatorProxyError - all facilitators are busy. Please retry after a few seconds."
- Missing: Actual HTTP status text and response body with specific error details
Result: Developers lose critical debugging information. A 503 with detailed maintenance message becomes indistinguishable from a 429 rate limit error.
Expected: Error should include HTTP status, status text, and response body as it did before commit 09a28f2 (Nov 5, 2025)
Git evidence: Commit 09a28f2 removed lines capturing errorBody = await res.text() and errorMsg = and replaced with generic throw new FacilitatorProxyError()
No description provided.