Skip to content

Conversation

@yhwang
Copy link
Member

@yhwang yhwang commented Nov 18, 2025

Description

Treat the incorrect duration data as 0 and avoid parsing errors. Meanwhile, also generate an error log in the console to show the wrong value.

Motivation and Context

fixed: #26588

Impact

An incorrect format, like a negative number, is treated as 0.

Test Plan

Verify the UI with negative numbers in the JSON payload

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

treat the incorrect duration data as `0` and avoid
parsing error. meanwhile, also generate error log in
the console to show the incorrect value.

Signed-off-by: Yihong Wang <[email protected]>
@yhwang yhwang requested a review from a team as a code owner November 18, 2025 23:32
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Nov 18, 2025
@prestodb-ci prestodb-ci requested review from a team, namya28 and sh-shamsan and removed request for a team November 18, 2025 23:32
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 18, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR updates parseDuration in utils.ts to treat incorrect or unsupported duration formats as 0 with console error logging and adjusts its return signature to always return a number.

Class diagram for updated parseDuration function

classDiagram
    class utils {
        +parseDuration(value: string): number
    }
Loading

Flow diagram for parseDuration error handling

flowchart TD
    A["Input duration string"] --> B["Match with DURATION_PATTERN"]
    B -- "No match" --> C["Log error: Invalid duration format"]
    C --> D["Return 0"]
    B -- "Match" --> E["Parse number and unit"]
    E -- "Supported unit" --> F["Calculate duration in ms"]
    F --> G["Return calculated value"]
    E -- "Unsupported unit" --> H["Log error: Failed to convert to float"]
    H --> D
Loading

File-Level Changes

Change Details Files
Enhanced parseDuration to default invalid inputs to zero with error logging
  • Changed return type from nullable to always number
  • On regex mismatch, log an error and return 0 instead of null
  • On unsupported unit fallback, log an error and return 0 instead of null
presto-ui/src/utils.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#26588 Fix the UI bug where Query Details page shows blank due to a TypeError when parsing duration values.
#26588 Handle incorrect or malformed duration formats in the UI code to prevent runtime errors.
#26588 Log errors to the console when an incorrect duration format is encountered for easier debugging.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@yhwang yhwang changed the title fix(ui): handle incorrect duration format fix(ui): Handle incorrect duration format Nov 19, 2025
@yhwang
Copy link
Member Author

yhwang commented Nov 19, 2025

Attached the manual verification:

Before the change, if the JSON payload contained invalid durations: negative values, the page would hit the error mentioned in #26588
Screenshot 2025-11-19 at 11 18 28 AM

After the change, the incorrect duration values are treated as 0 now. The page can properly show the statistics.
Screenshot 2025-11-19 at 11 13 53 AM

and error messages show up in the console:
image

@yhwang
Copy link
Member Author

yhwang commented Nov 19, 2025

Minor fix and no functionality change. Thanks to @tdcmeehan 's approval. Let me merge the change.

@yhwang yhwang merged commit ea7978b into prestodb:master Nov 19, 2025
112 of 118 checks passed
@yhwang yhwang deleted the querydetails-negative-value branch November 19, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Presto UI shows blank for Query Details

3 participants