Skip to content

Commit 0108cd2

Browse files
fix(telemetry): strip raw input from valibot issues before Sentry.setContext
1 parent 975cdfb commit 0108cd2

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎packages/cli/src/lib/api/infrastructure.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,16 @@ export async function apiRequestToRegion<T>(
529529
// Attach structured validation issues to the Sentry event so we can
530530
// diagnose exactly which field(s) failed validation — the ApiError.detail
531531
// string alone may not be visible in the Sentry issue overview.
532+
// Strip valibot issues to metadata only (path/type/message) before
533+
// attaching — full issues embed the raw failing `input` value.
532534
Sentry.setContext("schema_validation", {
533535
endpoint,
534536
status: response.status,
535-
issues: result.issues.slice(0, 10),
537+
issues: result.issues.slice(0, 10).map((i) => ({
538+
path: i.path,
539+
type: i.type,
540+
message: i.message,
541+
})),
536542
});
537543
throw new ApiError(
538544
`Unexpected response format from ${endpoint}`,

‎packages/cli/src/lib/api/logs.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,15 @@ function safeParseResponse<T>(
9898
assertObjectResponse(data, context);
9999
const result = safeParse(schema, data);
100100
if (!result.success) {
101+
// Strip valibot issues to metadata only (path/type/message) before
102+
// attaching to Sentry — full issues embed the raw failing `input` value.
101103
Sentry.setContext("schema_validation", {
102104
context,
103-
issues: result.issues.slice(0, 10),
105+
issues: result.issues.slice(0, 10).map((i) => ({
106+
path: i.path,
107+
type: i.type,
108+
message: i.message,
109+
})),
104110
});
105111
throw new ApiError(
106112
`${context}: unexpected response format`,

0 commit comments

Comments
 (0)