Initial commit to move to common package#165
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the codebase to offload authentication and OAuth handling to the newly introduced @thoughtspot/mcp-auth package, allowing the removal of several local handlers, utility files, and their corresponding tests. The review feedback highlights potential runtime TypeErrors due to type mismatches of clientName (which may be a string from the package but is expected to be an object locally) in both extendProps and enrichMcpRequestProps. Additionally, a defensive check is recommended when accessing the ASSETS binding to prevent crashes in environments where it might be missing.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const props: Props = { | ||
| ...base, | ||
| clientName: (base.clientName ?? { | ||
| clientId: "Bearer Token client", | ||
| clientName: "Bearer Token client", | ||
| registrationDate: Date.now(), | ||
| }) as Props["clientName"], | ||
| }; |
There was a problem hiding this comment.
The base.clientName property from the package might be a string (as indicated by the type cast and comments on line 128). If it is a string, base.clientName ?? { ... } will evaluate to that string, violating the local Props["clientName"] object structure at runtime. This can cause downstream runtime TypeErrors when properties like clientName.clientId are accessed. We should defensively normalize it to the expected object structure.
| const props: Props = { | |
| ...base, | |
| clientName: (base.clientName ?? { | |
| clientId: "Bearer Token client", | |
| clientName: "Bearer Token client", | |
| registrationDate: Date.now(), | |
| }) as Props["clientName"], | |
| }; | |
| const rawClientName = base.clientName; | |
| const props: Props = { | |
| ...base, | |
| clientName: (typeof rawClientName === "object" && rawClientName !== null | |
| ? rawClientName | |
| : { | |
| clientId: typeof rawClientName === "string" ? rawClientName : "Bearer Token client", | |
| clientName: typeof rawClientName === "string" ? rawClientName : "Bearer Token client", | |
| registrationDate: Date.now(), | |
| }) as Props["clientName"], | |
| }; |
| return { | ||
| ...(baseProps as Props), | ||
| apiVersion, | ||
| apiRequestedVersion: requestedApiVersion | ||
| ? normalizeRequestedApiVersionForAnalytics(requestedApiVersion) | ||
| : undefined, | ||
| apiVersionMode, | ||
| }; |
There was a problem hiding this comment.
Similar to extendProps, baseProps.clientName might be a string at runtime depending on the OAuth provider's payload. Casting baseProps as Props directly without normalizing clientName can lead to runtime TypeErrors when downstream code expects clientName to be an object. Let's defensively normalize it here as well.
const rawClientName = (baseProps as any)?.clientName;
return {
...(baseProps as Props),
clientName: (typeof rawClientName === "object" && rawClientName !== null
? rawClientName
: {
clientId: typeof rawClientName === "string" ? rawClientName : "Bearer Token client",
clientName: typeof rawClientName === "string" ? rawClientName : "Bearer Token client",
registrationDate: Date.now(),
}) as Props["clientName"],
apiVersion,
apiRequestedVersion: requestedApiVersion
? normalizeRequestedApiVersionForAnalytics(requestedApiVersion)
: undefined,
apiVersionMode,
};| app.get("/", async (c) => { | ||
| return c.env.ASSETS!.fetch("/index.html"); | ||
| }); |
There was a problem hiding this comment.
If the Cloudflare Workers environment is not configured with the ASSETS binding (e.g., during certain local testing setups or alternative deployment targets), accessing c.env.ASSETS!.fetch will throw a runtime TypeError. We should add a defensive check to handle this gracefully.
app.get("/", async (c) => {
if (!c.env.ASSETS) {
return c.text("Assets binding is missing", 500);
}
return c.env.ASSETS.fetch("/index.html");
});d398462 to
4205ee4
Compare
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
aditya-mcp-server | 4205ee4 | Jun 25 2026, 06:17 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
mcp-server | 4205ee4 | Jun 25 2026, 06:18 AM |
No description provided.