Repository navigation
test(python): cover bridge version mismatch diagnostic - #4380
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Python engine tests now import bridge and toolchain version accessors. They verify that incompatible bytecode raises a detailed ChangesRuntime version validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
Binary size checks passed✅ 7 passed
Generated by |
## Summary - add `baml toolchain pin <canary|nightly|version|path>` to select a project-local toolchain in the nearest `baml.toml` - share installation, channel activation, and local-path validation behavior with `baml toolchain use` - preserve manifest formatting and comments while replacing conflicting `toolchain.version`, `toolchain.channel`, or `toolchain.path` selectors - update generated-bytecode version-skew diagnostics to recommend the executable pin command - identify each bridge's package ecosystem in upgrade guidance, including “the Python package,” npm, Go, Rust, NuGet, Maven, Swift, and C++ ## Why The existing version-skew error told users to pin `toolchain.version` manually or change their machine-wide default with `baml toolchain use`. BAML did not provide a command that performed the project-local edit. This makes the primary recovery path directly executable, supports the same selector forms as `baml toolchain use`, and keeps the alternative bridge-upgrade guidance specific to the active SDK ecosystem. ## Behavior ```text baml toolchain pin canary baml toolchain pin nightly baml toolchain pin 0.15.1-nightly.20260807.a baml toolchain pin ./target/debug/baml-cli ``` The command: - finds the nearest `baml.toml` from the current directory - validates the manifest before downloading or writing - installs exact versions when missing - installs and activates channel selections - validates local binaries and stores a normalized path - atomically writes the matching `[toolchain]` key: `version`, `channel`, or `path` - removes conflicting selectors while preserving TOML comments and formatting ## Validation - `cargo test -p baml -p bridge_cffi` — 43 wrapper unit tests, 5 wrapper integration tests, 37 bridge unit tests, and bridge ABI/header/unhandled-spawn tests passed - `cargo clippy -p baml -p bridge_cffi --all-targets -- -D warnings` - `cargo fmt --all -- --check` - rebuilt the Python bridge with `uv run maturin develop --uv` - `uv run pytest -n 0 tests/test_engine.py::TestBasics::test_generated_bytecode_version_skew_fails_before_deserialization -q` — 1 passed - `uv run ruff check tests/test_engine.py` - `git diff --check` Linear: [B-1123](https://linear.app/boundaryml2/issue/B-1123/bytecode-version-skew-errors) Follow-up to [BoundaryML#4315](BoundaryML#4315) and [BoundaryML#4380](BoundaryML#4380). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added `baml toolchain pin` to select a project-specific toolchain by version, release channel, or local executable path. - Toolchain settings are saved in the nearest project manifest, with paths normalized automatically. - Added offline status support for verifying pinned toolchains. - **Bug Fixes** - Improved version-mismatch guidance with clear steps to pin or upgrade the toolchain and regenerate code. - Preserved existing manifest formatting and comments when updating toolchain settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Root cause and relation to #4315
The B-1473 report used generator
0.15.1-nightly.20260731.awithbaml_bridge==0.15.0. That generator predates #4315 and emitted only raw bytecode, so the bridge had no independently readable generator identity and surfacedUnexpected variant tag: 7.#4315 already fixed the supported regenerated-SDK path by embedding generation metadata and validating it before deserialization. Current coverage tests metadata emission and core
bridge_cffidiagnostics separately; this PR closes the remaining Python host-boundary gap.Legacy SDKs generated before #4315 must be regenerated to gain the compatibility preflight because their raw-bytecode-only payload has no toolchain identity to inspect.
Controlled reproduction
0.15.1-nightly.20260731.a0.15.0BamlPanic: Failed to deserialize BAML bytecode: Unexpected variant tag: 70.16.00.15.1.dev2026080700RuntimeErrorbefore deserialization with generated, installed, and required versions plus repair guidanceValidation
uv run pytest -n 0 tests/test_engine.py::TestBasics -q— 4 passed, 1 expected xfailcargo test -p bridge_cffi generated_metadata_tests— 5 passeduv run ruff check tests/test_engine.pygit diff --checkLinear: B-1473
Summary by CodeRabbit