-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix(ui): Handle incorrect duration format #26651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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]>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe 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 functionclassDiagram
class utils {
+parseDuration(value: string): number
}
Flow diagram for parseDuration error handlingflowchart 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
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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 After the change, the incorrect duration values are treated as |
|
Minor fix and no functionality change. Thanks to @tdcmeehan 's approval. Let me merge the change. |



Description
Treat the incorrect duration data as
0and 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
Release Notes
Please follow release notes guidelines and fill in the release notes below.