Skip to content

fix: testcase failed ococcasionally - #58

Closed
IceCodeNew wants to merge 1 commit into
jpillora:masterfrom
IceCodeNew:chore
Closed

IceCodeNew wants to merge 1 commit into
jpillora:masterfrom
IceCodeNew:chore

Conversation

@IceCodeNew

Copy link
Copy Markdown
Contributor

No description provided.

@jpillora

Copy link
Copy Markdown
Owner

Thanks for catching this — the flake was real: linux/amd64 resolved to yt-dlp_linux.zip (glibc) or yt-dlp_musllinux.zip (musl) at random, roughly 1 in 7 runs.

Rather than relaxing the assertion, I fixed the root cause in the handler in 2028bfe.

Root cause: "assumed" assets (filenames with no explicit os/arch token) are collected into a map in getAssetsNoCache and then merged into the result via for _, cAsset := range candidates — a randomized Go map iteration. When two assumed assets collapse to the same os/arch slot (glibc yt-dlp_linux.ziplinux/amd64 and musl yt-dlp_musllinux.zip/amd64, both normalizing to linux/amd64), whichever the map visited first won. Fixed input, random output.

Fix: candidates are now resolved through a total order before gap-filling the index:

  • Asset.preferredOver — prefer musl over glibc (portability), then avoid gnu, then break ties by name. Because it's a total order, the winner is independent of map iteration order.
  • exact os/arch matches still beat assumed assets, so e.g. linux/arm64 stays yt-dlp_linux_aarch64.

Added TestAssumedAssetDeterministic (100 iterations/run) guarding both invariants; TestYtDlp is now stable over 25+ runs and the strict linux/amd64 → yt-dlp_musllinux.zip assertion is kept, so it continues to guard the musl preference.

Since the handler is deterministic now, this test change isn't needed — closing. Thanks again for the report and the clear repro!

@jpillora jpillora closed this Jul 10, 2026
@IceCodeNew
IceCodeNew deleted the chore branch July 12, 2026 08:23
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