Repository navigation
Ignore the build-time git version in test env overrides - #1326
Conversation
The core build script exports TRUSTED_SERVER__GIT_VERSION with cargo:rustc-env, and Cargo also sets it on every cargo test run of the crate. The test-only from_toml_and_env loader reads every TRUSTED_SERVER__ variable as a settings override, so the variable is deserialized as an unknown git_version field and settings loading fails. Native `cargo test -p trusted-server-core --lib` fails 11 env override tests. CI runs core unit tests only on wasm32-wasip1 under Viceroy, which does not pass the host environment to the guest, so it never sees the variable. Setting it explicitly in the test reproduces the failure on both targets.
from_toml_and_env now reads overrides from a copy of the environment without TRUSTED_SERVER__GIT_VERSION. That name is a build input that shares the settings prefix, and Cargo exports it to every cargo test run of the crate through cargo:rustc-env. Runtime loading is unaffected: the EdgeZero overlay only overrides keys that already exist in the config.
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Approved. Focused fix to exclude the build-time TRUSTED_SERVER__GIT_VERSION from test environment overrides, with regression coverage for the deserialization failure.
dhruv8sh
left a comment
There was a problem hiding this comment.
Summary
Clean, well-scoped fix: from_toml_and_env now reads overrides from a copy of the environment without the build-time TRUSTED_SERVER__GIT_VERSION, so native cargo test -p trusted-server-core --lib passes again. Verified locally on x86_64-unknown-linux-gnu: 2939 passed with the fix; with the filter disabled, 12 settings tests fail (the 11 existing env-override tests plus the new regression test). Also confirmed the runtime claim — the EdgeZero overlay (apply_env_overlay) only overrides keys that already exist, so ts deploy with the variable set is unaffected.
1 of the inline comments below carries a one-click GitHub
suggestion— use Commit suggestion to apply it. The remaining comments are informational.
Non-blocking
🤔 thinking / ⛏ nitpick / 📝 note
- Build input shares the settings prefix — see inline at
crates/trusted-server-core/src/settings.rs:37 - Case-sensitive deny-list vs. case-insensitive
configmatching — see inline atcrates/trusted-server-core/src/settings.rs:3063 - Non-UTF-8 values are now skipped instead of erroring — see inline at
crates/trusted-server-core/src/settings.rs:3062
👍 praise
- Regression test that reproduces under Viceroy — see inline at
crates/trusted-server-core/src/settings.rs:6320
Cross-cutting / body-level findings
- 📌 Core unit tests never run natively in CI — this regression slipped through because CI runs
trusted-server-coreunit tests only onwasm32-wasip1under Viceroy, which does not pass the host environment to the guest; the only native core run is--test template_build_digest. Suggest opening a follow-up issue to add a nativecargo test -p trusted-server-core --libjob (host triple) to CI, which would catch this whole class of host-env / build-script interaction bugs.
CI Status
- integration tests: PASS
- browser integration tests: PASS
- integration tests (Fastly EC lifecycle): PASS
- cargo check/build/test (spin native + wasm32-wasip1): PASS
- format-docs: PASS (required)
- cargo check (cloudflare native + wasm32-unknown-unknown): PASS
- format-typescript: PASS (required)
- Analyze (rust): PASS
- cargo test (axum native): PASS
- cargo test (ts CLI, native) (ubuntu-latest): PASS
- prepare integration artifacts: PASS
- vitest: PASS
- cargo test: PASS (required)
- Analyze (javascript-typescript): PASS
- CodeQL: PASS
- Analyze (actions): PASS
- cargo fmt: PASS (required)
- CLAUDE.md symlink guard: PASS
- Analyze (python): PASS
- cargo test (ts CLI, native) (macos-latest): PASS
- cargo test (cross-adapter parity): PASS
Summary
cargo test -p trusted-server-core --libfails 11 settings env override tests onmainsince Report deployed git version in x-ts-version #1213. The core build script exportsTRUSTED_SERVER__GIT_VERSIONwithcargo:rustc-env, and Cargo also sets that variable on everycargo testrun of the crate. The test-onlySettings::from_toml_and_envloader reads everyTRUSTED_SERVER__variable as a settings override, so it deserializes an unknowngit_versionfield and fails withFailed to deserialize configuration.wasm32-wasip1under Viceroy, which does not pass the host environment to the guest. The only native core run in CI is--test template_build_digest.Changes
crates/trusted-server-core/src/settings.rsfrom_toml_and_envreads overrides from a copy of the environment withoutTRUSTED_SERVER__GIT_VERSION. Adds a regression test that sets the variable explicitly, so it fails under Viceroy too.The first commit adds the failing test and the second adds the fix.
Closes
Closes #1327
Found while reviewing #1325.
Test plan
cargo test-fastly && cargo test-axumcargo clippy-fastly && cargo clippy-axumcargo fmt --all -- --checkcd crates/trusted-server-js/lib && npx vitest runcd crates/trusted-server-js/lib && npm run formatcd docs && npm run formatcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute servecargo test -p trusted-server-core --target aarch64-apple-darwin --libwent from 11 failures to 2939 passed. The new test fails under Viceroy at the first commit withFailed to deserialize configurationand passes at the second.cargo test-cloudflareandcargo clippy-cloudflarealso pass.Checklist
unwrap()in production code — useexpect("should ...")tracingmacros (notprintln!)