Skip to content

Reject a zoom range that ends before it starts in profiler-cli - #6522

Open
canova wants to merge 2 commits into
mainfrom
canova/reject-inverted-ranges
Open

canova wants to merge 2 commits into
mainfrom
canova/reject-inverted-ranges

Conversation

@canova

@canova canova commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Main | Deploy preview

Before this PR, profiler-cli zoom push 3,2 committed an inverted range. Every query after would come back empty, with a negative duration in the header and no explanation why. Now it fails with Invalid range "3,2": it ends before it starts. Put the earlier time first..

The first commit moves the range and time value parsing out of pushViewRange into _resolveRangeSpec and _resolveTimeValue. That keeps the check in one place, and lets the screenshot commands in the next PR take the same syntax as zoom push.

Resolving a range spec ("2.7,3.1", "ts-6,ts-12", "m-158") and a single
time value now live in their own methods, so commands other than "zoom
push" can accept the same syntax without changing the zoom.
"zoom push 3,2" committed an inverted range. Every query after it was
empty, with a negative duration in the header and no explanation why.
Fail with an explanation instead.
@canova
canova requested review from fatadel and a balanced review from Copilot December 4, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Marker ranges return before the ordering check in src/profile-query/index.ts, so an interval marker whose end precedes its start can still commit an inverted zoom, producing empty queries and a negative duration. Interval derivation preserves these endpoints unchanged, so a non-null end does not guarantee valid ordering.

1 open issue
What changed in this PR

Adds inverted-range rejection to profiler-cli zoom push through the shared profile-query layer.

Changes:

  • Extracts time and range parsing for reuse by upcoming screenshot commands.
  • Rejects reversed time pairs with a clear error.
  • Adds a regression test for rejection without committing a range.
File Description
src/​test/​unit/​profile-query/​profile-querier.test.ts Tests inverted-range rejection and unchanged empty zoom state.
src/​profile-query/​index.ts Extracts parsing helpers and validates endpoint order.

Review effort: Balanced

Comment thread src/profile-query/index.ts Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants