Repository navigation
nvx: build the EXEC payload's truncation error and length-prefixed strings with one helper each - #2347
Queued
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Queued
nvx: build the EXEC payload's truncation error and length-prefixed strings with one helper each#2347Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Conversation
…rings with one helper each The EXEC codec spelled the error of a payload that ends early, "the exec request is truncated", at six sites: a local closure in decode_exec_header and inline literals in decode_exec, prefixed_string, and bytes_at. Its encoder also wrote each argument and environment entry with the same three lines, a u32 length and the bytes, which the decoder already reads through one prefixed_string. Name the error once in a module-level truncated(), as the MAPS codec does, and write the length-prefixed strings with push_prefixed(), the encoder's counterpart of prefixed_string. The message, its ProtocolError, the encoded bytes (including the saturating u32 conversion that the MAX_ARGUMENT_BYTES checks before it never reach), the order of the checks, and every cfg stay the same; no public item changes. The protocol tests pass unchanged at the base revision, 895d8f9 (109 passed, cargo test --all-features --lib protocol:: on Windows). New unit tests in protocol/exec/tests.rs read pushed strings back through prefixed_string, the longest included, and check that every shorter cut of one reads as the shared truncation error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the EXEC payload codec refactor.
No open issues 🎉
What changed in this PR
This PR addresses #2346 by consolidating repeated logic in the EXEC payload codec without changing the wire format, error messages, or public API.
Changes:
- Adds
push_prefixedto encode arguments and environment entries through one helper. - Uses a shared
truncated()function for decoder truncation errors. - Adds unit tests for length-prefixed string round-trips and truncated payloads.
| File | Description |
|---|---|
nvx/src/protocol/exec/tests.rs |
Adds round-trip and truncation tests for the string helpers. |
nvx/src/protocol/exec.rs |
Extracts the string-writing helper and centralizes truncation-error construction. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
added this pull request to the merge queue
Nov 28, 2026
Any commits made after this event will not be merged.
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.
Fixes #2346
What does this pull request change?
A behavior-preserving cleanup of the EXEC payload codec in
nvx/src/protocol/exec.rs. Start reading atencode_exec_payload.push_prefixedhelper. Before, it repeated the same three lines in both loops. The helper keeps theu32::try_from(..).unwrap_or(u32::MAX)saturation, so the encoded bytes are identical.decode_exec_headerdrops its localtruncatedclosure and calls the module'struncated()function. All six truncation sites now build one error, with the same message as before (the patternprotocol/maps.rsalready uses).nvx/src/protocol/exec/tests.rscheck thatpush_prefixedround-trips throughprefixed_string, and that a string cut short reports the truncation error.Error messages, wire format, and public API are unchanged. Validating arguments before writing them is left out on purpose, because it would change behavior; the issue records it as a follow-up.
Why is this change needed?
The truncation error was built in two ways, and the prefixed-string write was duplicated. Any future change to either could drift between copies. One helper each keeps the encoder and decoder consistent. I rejected moving the decoder to a separate module: it would touch far more lines for little gain.
How was this change validated?
Checks and results:
cargo test --locked --all-features --lib protocol::(innvx/): 109 passed. After the change: 111 passed (109 plus the 2 new tests).python scripts\local_gates.py --base origin/dev --run. All selected gates passed: test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-msrv, nvx-cli (withNVXset to a release build).cargo cleanfreed space, those gates were rerun with--onlyand passed.python3 scripts/local_gates.py --base origin/dev --run. All gates passed: test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-public-api, nvx-msrv, nvx-macos, nvx-guest-binaries-lint, nvx-guest-binaries-build, nvx-cli.guest.pip install(PEP 668, externally managed Python). In a venv withNVXset to a release build, it passed: 2326 tests OK (41 skipped) and 84 OK.Backend, host OS, host type, and guest: none. This is a host-side codec refactor, and I ran no microVM.
Left to CI: the microVM scenarios on KVM, MSHV, and WHP, and benchmarks.
Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes.
nvxupdatesnvx/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.