-
Notifications
You must be signed in to change notification settings - Fork 0
feat: distributed tracing - 3 #10
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
base: eval-pr-25092-target-1763483260809
Are you sure you want to change the base?
Changes from all commits
f6aa35d
8ac527a
49083c1
fef1027
1cb772a
dc3edc2
cdb1cd0
11b5f70
b652210
9042d18
a821001
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 |
|---|---|---|
|
|
@@ -323,6 +323,12 @@ const getError = ({ | |
| return error?.message ? ( | ||
| <> | ||
| {responseVercelIdHeader ?? ""} {t(messageKey, { date, count })} | ||
| {error.data?.traceId && ( | ||
| <div className="text-subtle mt-2 text-xs"> | ||
| <span className="font-medium">{t("trace_reference_id")}:</span> | ||
|
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. The new trace reference label calls an undefined translation key, so users will see the literal key text instead of a localized string. Add the entry to the locale files to keep the UI consistent. Prompt for AI agents[internal] Confidence score: 7/10 [internal] Posted by: General AI Review Agent
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. The new label calls Prompt for AI agents[internal] Confidence score: 9/10 [internal] Posted by: General AI Review Agent |
||
| <code className="ml-1 select-all break-all font-mono">{error.data.traceId}</code> | ||
| </div> | ||
| )} | ||
| </> | ||
| ) : ( | ||
| <>{t("can_you_try_again")}</> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,9 +5,13 @@ import { ErrorCode } from "@calcom/lib/errorCodes"; | |||||
| import { ErrorWithCode } from "@calcom/lib/errors"; | ||||||
| import { Prisma } from "@calcom/prisma/client"; | ||||||
|
|
||||||
| import { TRPCError } from "@trpc/server"; | ||||||
| import { getHTTPStatusCodeFromError } from "@trpc/server/http"; | ||||||
|
|
||||||
| import { HttpError } from "../http-error"; | ||||||
| import { redactError } from "../redactError"; | ||||||
| import { stripeInvalidRequestErrorSchema } from "../stripe-error"; | ||||||
| import { TracedError } from "../tracing/error"; | ||||||
|
|
||||||
| function hasName(cause: unknown): cause is { name: string } { | ||||||
| return !!cause && typeof cause === "object" && "name" in cause; | ||||||
|
|
@@ -34,37 +38,71 @@ function parseZodErrorIssues(issues: ZodIssue[]): string { | |||||
| } | ||||||
|
|
||||||
| export function getServerErrorFromUnknown(cause: unknown): HttpError { | ||||||
| let traceId: string | undefined; | ||||||
| let tracedData: Record<string, unknown> | undefined; | ||||||
|
|
||||||
| if (cause instanceof TracedError) { | ||||||
|
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. The unwrapping logic for Reasoning: Prompt for AI agents[internal] Confidence score: 8/10 [internal] Posted by: System Design Agent |
||||||
| traceId = cause.traceId; | ||||||
| tracedData = cause.data; | ||||||
| cause = cause.originalError; | ||||||
| } | ||||||
|
|
||||||
| if (cause instanceof TRPCError) { | ||||||
| const statusCode = getHTTPStatusCodeFromError(cause); | ||||||
| return new HttpError({ | ||||||
| statusCode, | ||||||
| message: cause.message, | ||||||
| data: traceId ? { ...tracedData, traceId } : undefined, | ||||||
|
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.
Reasoning: Prompt for AI agents[internal] Confidence score: 8/10 [internal] Posted by: General AI Review Agent
Suggested change
|
||||||
| }); | ||||||
| } | ||||||
| if (isZodError(cause)) { | ||||||
| return new HttpError({ | ||||||
| statusCode: 400, | ||||||
| message: parseZodErrorIssues(cause.issues), | ||||||
| cause, | ||||||
| data: traceId ? { ...tracedData, traceId } : undefined, | ||||||
| }); | ||||||
| } | ||||||
| if (cause instanceof SyntaxError) { | ||||||
| return new HttpError({ | ||||||
| statusCode: 500, | ||||||
| message: "Unexpected error, please reach out for our customer support.", | ||||||
| data: traceId ? { ...tracedData, traceId } : undefined, | ||||||
| }); | ||||||
| } | ||||||
| if (isPrismaError(cause)) { | ||||||
| return getServerErrorFromPrismaError(cause); | ||||||
| const prismaError = getServerErrorFromPrismaError(cause); | ||||||
| return new HttpError({ | ||||||
| statusCode: prismaError.statusCode, | ||||||
| message: prismaError.message, | ||||||
| cause: prismaError.cause, | ||||||
| data: traceId ? { ...tracedData, ...prismaError.data, traceId } : prismaError.data, | ||||||
cubic-dev-local[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| }); | ||||||
| } | ||||||
| const parsedStripeError = stripeInvalidRequestErrorSchema.safeParse(cause); | ||||||
| if (parsedStripeError.success) { | ||||||
| return getHttpError({ statusCode: 400, cause: parsedStripeError.data }); | ||||||
| const stripeErrorObj = new Error(parsedStripeError.data.message || "Stripe error"); | ||||||
| stripeErrorObj.name = parsedStripeError.data.type || "StripeInvalidRequestError"; | ||||||
| const stripeError = getHttpError({ statusCode: 400, cause: stripeErrorObj }); | ||||||
| return new HttpError({ | ||||||
| statusCode: stripeError.statusCode, | ||||||
| message: stripeError.message, | ||||||
| cause: stripeError.cause, | ||||||
| data: traceId ? { ...tracedData, ...stripeError.data, traceId } : stripeError.data, | ||||||
|
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. Trying to spread Reasoning: Prompt for AI agents[internal] Confidence score: 8/10 [internal] Posted by: General AI Review Agent
Suggested change
|
||||||
| }); | ||||||
| } | ||||||
| if (cause instanceof ErrorWithCode) { | ||||||
| const statusCode = getStatusCode(cause); | ||||||
| return new HttpError({ | ||||||
| statusCode, | ||||||
| message: cause.message ?? "", | ||||||
| data: cause.data, | ||||||
| data: traceId ? { ...cause.data, ...tracedData, traceId } : cause.data, | ||||||
| cause, | ||||||
| }); | ||||||
| } | ||||||
| if (cause instanceof HttpError) { | ||||||
| const redactedCause = redactError(cause); | ||||||
| const originalData = cause.data; | ||||||
| return { | ||||||
| ...redactedCause, | ||||||
| name: cause.name, | ||||||
|
|
@@ -73,22 +111,35 @@ export function getServerErrorFromUnknown(cause: unknown): HttpError { | |||||
| url: cause.url, | ||||||
| statusCode: cause.statusCode, | ||||||
| method: cause.method, | ||||||
| data: traceId ? { ...originalData, ...tracedData, traceId } : originalData, | ||||||
| }; | ||||||
| } | ||||||
| if (cause instanceof Error) { | ||||||
| const statusCode = getStatusCode(cause); | ||||||
| return getHttpError({ statusCode, cause }); | ||||||
| const error = getHttpError({ statusCode, cause }); | ||||||
| return new HttpError({ | ||||||
| statusCode: error.statusCode, | ||||||
| message: error.message, | ||||||
| cause: error.cause, | ||||||
| data: traceId ? { ...tracedData, ...error.data, traceId } : error.data, | ||||||
cubic-dev-local[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| }); | ||||||
| } | ||||||
| if (typeof cause === "string") { | ||||||
| // @ts-expect-error https://github.com/tc39/proposal-error-cause | ||||||
cubic-dev-local[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| const error = new Error(cause, { cause }); | ||||||
| const httpError = getHttpError({ statusCode: 500, cause: error }); | ||||||
| return new HttpError({ | ||||||
| statusCode: 500, | ||||||
| message: cause, | ||||||
| statusCode: httpError.statusCode, | ||||||
| message: httpError.message, | ||||||
| cause: httpError.cause, | ||||||
| data: traceId ? { ...tracedData, ...httpError.data, traceId } : httpError.data, | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| return new HttpError({ | ||||||
| statusCode: 500, | ||||||
| message: `Unhandled error of type '${typeof cause}'. Please reach out for our customer support.`, | ||||||
| data: traceId ? { ...tracedData, traceId } : tracedData, | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
t("trace_reference_id")introduces a new translation key, but no locale entry exists for it, so the UI will render the raw key text instead of a localized label. Please add the string to the locale files when adding a newt()usage.Prompt for AI agents
[internal] Confidence score: 9/10
[internal] Posted by: General AI Review Agent