Skip to content

fix(v3-client): Guard trace summary timestamp params against out-of-range Date - #4302

Open
okxint wants to merge 4 commits into
jaegertracing:mainfrom
okxint:fix/trace-summary-timestamp-range
Open

fix(v3-client): Guard trace summary timestamp params against out-of-range Date#4302
okxint wants to merge 4 commits into
jaegertracing:mainfrom
okxint:fix/trace-summary-timestamp-range

Conversation

@okxint

@okxint okxint commented Jul 30, 2026

Copy link
Copy Markdown

Problem

fetchTraceSummaries guards startUs/endUs with Number.isFinite, but Number.isFinite(1e20) is true. Values that large (beyond Date's maximum of 8.64×10¹⁵ ms) cause new Date(startUs / 1000).toISOString() to throw RangeError: Invalid time value, crashing the function before fetch() is ever called.

Fix

Introduce an intermediate Date object and guard with Number.isFinite(date.getTime()) before serialising. new Date() with an out-of-range argument produces an Invalid Date whose getTime() returns NaN, so Number.isFinite(NaN) === false silently drops the parameter — matching the existing comment "drop malformed URL params gracefully" and consistent with how the Number.isFinite(startUs) check above it works for non-finite inputs.

-    if (Number.isFinite(startUs) && startUs > 0)
-      params.set('query.startTimeMin', new Date(startUs / 1000).toISOString());
-    if (Number.isFinite(endUs) && endUs > 0)
-      params.set('query.startTimeMax', new Date(endUs / 1000).toISOString());
+    const startDate = Number.isFinite(startUs) && startUs > 0 ? new Date(startUs / 1000) : null;
+    if (startDate && Number.isFinite(startDate.getTime()))
+      params.set('query.startTimeMin', startDate.toISOString());
+    const endDate = Number.isFinite(endUs) && endUs > 0 ? new Date(endUs / 1000) : null;
+    if (endDate && Number.isFinite(endDate.getTime()))
+      params.set('query.startTimeMax', endDate.toISOString());

Fixes #4284

okxint added 4 commits June 17, 2026 10:56
Signed-off-by: okxint <cashmein.eth@gmail.com>
Signed-off-by: okxint <cashmein.eth@gmail.com>
The pad_start formatter logs an error when desiredLength is NaN but
then falls through to call value.padStart(NaN, padCharacter) instead
of returning early. The add formatter in the same file correctly
returns early in the equivalent NaN branch.

This produces the correct output by accident today — padStart(NaN, ...)
coerces NaN to 0 and returns the original string — but the error message
claims formatting is being ignored while the code keeps executing,
making the two formatters inconsistent and fragile under future changes.

Add the missing return value; to match the documented and logged
behavior.

Fixes jaegertracing#4284

Signed-off-by: okxint <cashmein.eth@gmail.com>
…ange Date

Number.isFinite(startUs) passes values like 1e20 (beyond Date's max of
8.64e15 ms). new Date(1e20 / 1000).toISOString() throws RangeError:
Invalid time value, crashing fetchTraceSummaries before fetch() is called.

Introduce an intermediate Date and guard with Number.isFinite(date.getTime())
before serialising. new Date() with an out-of-range argument produces an
Invalid Date whose getTime() returns NaN, so Number.isFinite(NaN) === false
drops the parameter gracefully, matching the existing comment.

Fixes jaegertracing#4284

Signed-off-by: okxint <cashmein.eth@gmail.com>
@okxint
okxint requested a review from a team as a code owner July 30, 2026 15:37
@github-actions github-actions Bot added the pr-quota-reached PR is on hold due to quota limits for new contributors label Jul 30, 2026
@github-actions

Copy link
Copy Markdown

Hi @okxint, thanks for your contribution! To ensure quality reviews, we limit how many concurrent PRs new contributors can open:

  • Open: 4
  • Limit: 1

This PR is currently on hold. We will automatically move this into the review queue once your existing PRs are merged or closed.

Please see our Contributing Guidelines for details on our tiered quota policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-quota-reached PR is on hold due to quota limits for new contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Out-of-range search timestamps cause trace summary requests to fail

1 participant