fix(sdk-python): version ldflag + wrong-platform validation (PILOT-208 A+B)#5
Merged
Merged
Conversation
…8 side fixes) Two of three sub-fixes from PILOT-208. The third (CI publish-pipeline single-arch upload) remains blocked on the .github/workflows/ policy decision tracked in PILOT-113. Fix A: build-binaries.sh missing version ldflag `go build -ldflags="-s -w"` produced binaries that report "dev" for their version string at runtime. Added `-X main.Version=$SDK_VERSION` (SDK_VERSION is already parsed from pyproject.toml earlier in the script) so the four CLI binaries embed the wheel's version. The CGO binding doesn't have a main package — left alone. Fix B: _runtime.py wrong-platform validation Wheel bundled binaries get exec'd by cli.py / loaded by client.py. If pip installed a wrong-platform wheel (e.g. linux wheel on macOS), the failure surfaces as opaque "Exec format error" at first exec with no actionable diagnostic. Added _validate_binary_platform that sniffs the first 4 bytes of pilotctl for ELF / Mach-O / PE magic, compares to host platform, raises OSError with reinstall hint if there's a clear mismatch. Tightened to raise ONLY when a KNOWN binary format is detected that doesn't match — files with unrecognized headers (text stubs, empty files in test fixtures) pass through to the existing seeder pipeline unchanged. Caught by the existing test_missing_lib_does_not_crash_seeder test which was failing on the strict initial version. Verification: 55/55 sdk-python tests pass. _runtime.py coverage at 97%. Closes PILOT-208 (partially — sub-fixes A + B; root cause stays blocked).
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
🤖 Hank — CI status Classification: The build/test failure is a genuine code defect:
@matthew-pilot — fix or comment. Auto-classified at 2026-05-29T10:50:00Z. Re-runs on next push or check completion. |
Collaborator
|
🧹 Matthew cleanup — merged by TeoSlayer at 2026-05-29T14:32:10Z. Branch branch |
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.
Two of three PILOT-208 sub-fixes. Third (root cause: CI single-arch publish) stays blocked on PILOT-113 policy.
A — build-binaries.sh missing -X main.Version: binaries reported "dev" at runtime. Added
-X main.Version=$SDK_VERSIONto all 4go buildlines.B — wrong-platform wheel produced opaque Exec format error:
_validate_binary_platformsniffs the first 4 bytes of a bundled binary, compares to host platform (Linux/Darwin/Windows), raises a typed OSError with reinstall guidance if a KNOWN binary format doesn't match. Unrecognized headers pass through (preserves existing forgiving behavior for test stubs and missing libs).Blast radius: small. Both changes are additive. A is pure build-time metadata. B raises only on confirmed wrong-platform binary — files with unrecognized headers go through the existing seeder path unchanged (validated by the test suite's missing-lib stub test).
Verification: 55/55 sdk-python tests pass. New code at 97% coverage.
Closes PILOT-208 (partially — A+B; root cause stays blocked).