Skip to content

inspect/sort: Fix handling of non-hex strings with only hex characters#2888

Merged
smalis-msft merged 2 commits intomicrosoft:mainfrom
smalis-msft:natsortaibug
Mar 9, 2026
Merged

inspect/sort: Fix handling of non-hex strings with only hex characters#2888
smalis-msft merged 2 commits intomicrosoft:mainfrom
smalis-msft:natsortaibug

Conversation

@smalis-msft
Copy link
Contributor

If text doesn't have "0x" as a prefix it shouldn't be parsed as hex. Fix this and add a test to verify. Vibe found and coded with Claude 4.6.

@smalis-msft smalis-msft requested a review from a team as a code owner March 5, 2026 16:11
Copilot AI review requested due to automatic review settings March 5, 2026 16:11
@smalis-msft smalis-msft enabled auto-merge (squash) March 5, 2026 16:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates support/inspect’s natural-sort comparator so that digit-prefixed substrings are parsed as decimal unless explicitly marked as hex via a "0x" prefix, preventing unintended hex interpretation of strings like "3cab".

Changes:

  • Parse digit-prefixed numeric segments using base-10 instead of base-16 (hex parsing remains "0x"-prefixed only).
  • Add a unit test covering the regression case where a hex-letter suffix (a-f) previously caused unintended numeric parsing.

You can also share your feedback on Copilot code review. Take the survey.

@jstarks
Copy link
Member

jstarks commented Mar 6, 2026

I think this will break parts of the tree where we don't use a 0x prefix.

@jstarks
Copy link
Member

jstarks commented Mar 6, 2026

Actually, those are probably already broken when the first character is not 0-9...

@jstarks
Copy link
Member

jstarks commented Mar 6, 2026

Anyway, it would be good to look at inspect -r and see if there's anything for which we're going to regret losing the auto-hex behavior...

@smalis-msft
Copy link
Contributor Author

I skimmed through and didn't see anything. Everything's either properly prefixed or not actually hex.

@smalis-msft smalis-msft merged commit f02f8b0 into microsoft:main Mar 9, 2026
80 of 82 checks passed
@smalis-msft smalis-msft deleted the natsortaibug branch March 9, 2026 19:08
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.

5 participants