-
Notifications
You must be signed in to change notification settings - Fork 12k
fix: catch HttpError in getRoutedUrl #23844
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
Changes from all commits
2400435
a016898
578915f
d353b48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,10 +23,10 @@ import { withReporting } from "@calcom/lib/sentryWrapper"; | |
| import { PrismaRoutingFormRepository } from "@calcom/lib/server/repository/PrismaRoutingFormRepository"; | ||
| import { UserRepository } from "@calcom/lib/server/repository/user"; | ||
| import prisma from "@calcom/prisma"; | ||
|
|
||
| import { TRPCError } from "@trpc/server"; | ||
|
|
||
| import { getUrlSearchParamsToForward } from "./getUrlSearchParamsToForward"; | ||
| import { HttpError } from "@calcom/lib/http-error"; | ||
|
|
||
| const log = logger.getSubLogger({ prefix: ["[routing-forms]", "[router]"] }); | ||
| const querySchema = z | ||
|
|
@@ -171,7 +171,7 @@ const _getRoutedUrl = async (context: Pick<GetServerSidePropsContext, "query" | | |
| crmContactOwnerRecordType = result.crmContactOwnerRecordType; | ||
| crmAppSlug = result.crmAppSlug; | ||
| } catch (e) { | ||
| if (e instanceof TRPCError) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be safer to keep both, considering that if some fn somewhere starts throwing TRPCError or maybe throwing it currently.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| if (e instanceof HttpError || e instanceof TRPCError) { | ||
| return { | ||
| props: { | ||
| ...pageProps, | ||
|
|
@@ -181,7 +181,7 @@ const _getRoutedUrl = async (context: Pick<GetServerSidePropsContext, "query" | | |
| }, | ||
| }; | ||
| } | ||
|
|
||
| log.error("Error handling the response", safeStringify(e)); | ||
| throw new Error("Error handling the response"); | ||
| } | ||
|
|
||
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.
💡 Verification agent
🧩 Analysis chain
Ensure instanceof works: unify HttpError source across throw/catch sites
If upstream throws a different HttpError constructor (e.g., via a platform re‑export) than the one imported here,
instanceof HttpErrorwon’t match and the catch path won’t run. Verify that all throwers and checkers import the same symbol from the same module.Run to confirm a single canonical import path and where
HttpErroris thrown:🏁 Script executed:
Length of output: 183
🏁 Script executed:
Length of output: 4764
🏁 Script executed:
Length of output: 1031
🏁 Script executed:
Length of output: 198468
Ensure instanceof works: unify HttpError source across throw/catch sites
Repository contains two distinct HttpError classes (packages/lib/http-error.ts and apps/web/lib/core/http/error/http-error.ts). packages/features/routing-forms/lib/getRoutedUrl.ts imports "@calcom/lib/http-error" (import at line 29) and uses
if (e instanceof HttpError)(line 174) — that check will fail if a different HttpError constructor is thrown. Action: pick a single canonical HttpError (prefer @calcom/lib/http-error / packages/lib/http-error.ts), update all imports to that module (including app-local imports like @lib/core/http/error), or replaceinstanceofwith a shared type guard (e.g., isHttpError(error)) and/or a stable property check.🤖 Prompt for AI Agents