Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/cli/src/types/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,13 @@ export type DetailedLogsResponse = InferOutput<
*/
export const TraceItemAttributeSchema = variant("type", [
object({ name: string(), type: literal("str"), value: string() }),
object({ name: string(), type: literal("int"), value: number() }),
// Sentry serializes int64 values as strings to avoid precision loss
// (e.g. project_id: "4508608809533441"); keep them as strings.
object({
name: string(),
type: literal("int"),
value: union([number(), string()]),
}),
object({ name: string(), type: literal("float"), value: number() }),
object({ name: string(), type: literal("bool"), value: boolean() }),
// "array" is gated by organizations:trace-item-details-array-fields in Sentry backend
Expand Down
23 changes: 23 additions & 0 deletions packages/cli/test/lib/api/traces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,29 @@ describe("getSpanDetails", () => {
value: "db.query",
});
});

test("accepts int attributes serialized as strings", async () => {
mockOk({
...DETAIL_RESPONSE,
attributes: [
{ name: "project_id", type: "int", value: "4508608809533441" },
{ name: "retry.count", type: "int", value: 3 },
],
});

const result = await getSpanDetails(
"my-org",
"my-project",
"span-id-abc",
"trace-id-xyz",
);

// Strings are kept as-is so int64 IDs don't lose precision
expect(result.attributes).toEqual([
{ name: "project_id", type: "int", value: "4508608809533441" },
{ name: "retry.count", type: "int", value: 3 },
]);
});
});

// ---------------------------------------------------------------------------
Expand Down
Loading