Repository navigation
fix(model1): don't panic sorting a capacity column holding n/a or other text - #4309
Merged
Merged
Conversation
uozalp
approved these changes
Oct 20, 2026
uozalp
left a comment
Collaborator
There was a problem hiding this comment.
@kevin9327 thanks for this update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
capacityToNumber(used to sort capacity columns) callsresource.MustParse, which panics on any value that isn't a Kubernetes quantity. #3869 handled the empty string, but other non-quantity values still crash k9s when that column is sorted:Nattribute (|NsetsCapacity: true) showsn/awhenever its JSONPath finds nothing (cust_cols.gosetsv = NAValue). Sorting by that column takes down k9s withpanic: cannot parse 'n/a': quantities must match the regular expression ...<none>or text values such as1/3in anNcolumn.Fix
Use
resource.ParseQuantityinstead. A value that doesn't parse returnsmath.MaxInt64, so placeholders sort last, the same waydurationToSecondsalready handles<unknown>,<none>andn/ain age columns.Tests
I added
n/a,<none>and1/3cases toTestCapacityToNumber. Before the fix the test panics; after it,go test ./internal/model1passes.This PR was prepared with AI assistance. I reviewed and tested the change myself.