Skip to content

Commit 5250529

Browse files
committed
fix: restore try-catch around BigInt conversion in unixNanoToDateTime
BigInt(text) throws SyntaxError for non-integer strings (e.g. '12.34', 'abc'). Since this function processes external OTLP trace data, malformed input is realistic and callers have no surrounding error handling. Wrap the conversion in try-catch to gracefully return null on invalid input.
1 parent 00d4b68 commit 5250529

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

apps/server/src/diagnostics/TraceDiagnostics.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ function unixNanoToDateTime(value: unknown): DateTime.Utc | null {
9090
const text = toStringValue(value);
9191
if (!text) return null;
9292

93-
const millis = Number(BigInt(text) / 1_000_000n);
94-
return Option.getOrNull(DateTime.make(millis));
93+
try {
94+
const millis = Number(BigInt(text) / 1_000_000n);
95+
return Option.getOrNull(DateTime.make(millis));
96+
} catch {
97+
return null;
98+
}
9599
}
96100

97101
function readExitTag(exit: unknown): string | null {

0 commit comments

Comments
 (0)