Conversation
Apple ships some product types with a trailing variant (iPad16,4-A), which DeconstructDevice's regex did not match. SortDevices rebuilds every name from the parsed Device, so those product types came back as 0,0 and kernelcaches were written as kernelcache.release.0,0_0 instead of kernelcache.release.iPad16,3-A_4-A. Parse the optional suffix and carry it through Device.String and the sort key. Names that never matched the regex still collapse to the zero Device.
…list Adds the second DeconstructDevice caller (pkg/xcode ByProductType, which had no test file) and the sort-key rows the first pass left unpinned: strict ordering between two variants of one model, insertion-order independence, and a round trip over the variant-suffixed product types the embedded Xcode device_traits DB actually ships.
This branch has not been deployed
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.
Summary
utils.DeconstructDeviceparsed product types with the regex^([a-zA-Z]+)([0-9]+),([0-9]+)$, which does not match the variant-suffixed product types Apple ships (iPad16,4-A). On no match it returns the zeroDevice.utils.SortDevicesrebuilds every name it is handed from the parsed struct viaDevice.String(), so an unparsed name does not pass through unchanged — it comes back as the literal string"0,0".pkg/infofeeds product types straight intoSortDevices(info.go:629for kernelcache device lists,info.go:479for IPSW folder names), so an iPad Pro M4 kernelcache is written askernelcache.release.0,0_0instead ofkernelcache.release.iPad16,3-A_4-A.pkg/xcode'sByProductType.Lessis the other caller: on base every variant-suffixed product type sorted as the zeroDevice, soipsw device-listhoisted all 24 of them to the front of the list, ahead of AppleTV.pkg/xcode/data/device_traits.jsoncarry this suffix (iPad14,3-A/B through iPad17,4-A/B — the M2/M4 iPad Pro and Air lines). Measured over the full 250-entry corpus: base loses 24 of 250, the fix loses 0 of 250.Device.Variantfield and carry it throughString()and the sort key. Names that never matched the regex still collapse to the zeroDevice— unchanged.Whole-package totals on the base arm at this head: 27 PASS / 8 FAIL. All 8 failures are the discriminating tests on this branch; the 2 remaining added tests are declared controls.
This is a small, self-contained fix in one file (
internal/utils/sort.go, 10 changed lines), adjacent to but distinct from #1323 (a different, already-fixed cause of the same class of wrong kernelcache filename).Decisions
Four logical changes, 10 changed lines in one file. It is minimal because the round-trip is the contract that is broken:
SortDevicesrebuilds names from the struct, so anything the struct cannot hold is lost. Storing the suffix is the smallest change that makes the round trip lossless. Including it in theLesskey keeps the sort total and deterministic foriPad16,4/iPad16,4-A/iPad16,4-B, which would otherwise compare equal.Alternatives rejected:
-Acase by accident, but also stopsn66apand other non-product-type input from normalising to0,0, silently changing behaviour the existing code relies on. Larger blast radius, not smaller.pkg/info— pushes the knowledge of Apple's naming into a caller and leavespkg/xcode'sByProductType.Less(the otherDeconstructDevicecaller) still broken.pkg/infoonly — the defect is ininternal/utils; both call sites want the same corrected parse.var(a real, if small, performance win) — deliberately not done: it is an unrelated change to a function this PR is already touching, and one bug per PR.Not run:
make build(cgo dependency download not completed in this environment) —go vet ./internal/utils/ ./pkg/info/ ./pkg/xcode/is clean and the full test files for these three packages pass.AI assistance: this bug was found and the fix and tests were drafted with AI tooling in my workflow; the tests and checks above were executed as pasted. I'm responsible for the change and will handle review feedback.