Repository navigation
Conversation
|
Hi @chennaji9. Thanks for your PR. I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
The duplicated sort comparators in CLIPrinter::printSearchResult and JSONPrinter::printSearchResult returned false whenever either version failed to parse, making record equivalence non-transitive when mixed with parsable versions and violating std::sort's precondition (undefined behavior). Order parsable versions first descending as before and unparsable ones last by raw string, in both printers; add a unit test covering mixed parsable/unparsable versions through both printers. Signed-off-by: 陈那几 <2078634206@qq.com>
e3940e3 to
cc2e1b8
Compare
What does this PR do?
The search-result sort comparator is duplicated in
CLIPrinter::printSearchResultandJSONPrinter::printSearchResult, and it violates strict weak ordering:For records with equal id/channel/module: if either version fails to parse, the comparator returns false both ways — but two parsable versions still order against each other. Equivalence becomes non-transitive (e.g.
2.0.0,"",1.0.0), violatingstd::sort's precondition: undefined behavior (out-of-bounds reads / crashes depending on the sort path).Note:
Version::parsefalls through toFallbackVersion, which accepts almost any non-empty dotted string — the unparsable set is effectively{""}and dot-only strings (".",".."), which repo metadata can still carry.Order parsable versions first, descending, exactly as before; sort unparsable ones last, deterministically by raw version string. Apply the same fix to both printers so text and JSON output stay consistent.
Validation
CLIPrinter.PrintSearchResultSortsInvalidVersionsLastfeeds mixed parsable (3.0.0,2.0.0,1.0.0) and unparsable ("...","") versions with identical id/channel/module through BOTH printers and asserts the emitted order (3.0.0<2.0.0<1.0.0< invalid group) via output offsets.ctest -R 'CLIPrinter|JsonPrinter'→ 20/20 Passed, including the pre-existingPrintSearchResultSortsandPrintSearchResultEmpty).ll-testsbuilds cleanly.🤖 Generated with Claude Code