Skip to content

Ignore the build-time git version in test env overrides - #1326

Merged
aram356 merged 8 commits into
mainfrom
fix/native-settings-env-tests
Oct 22, 2026
Merged

aram356 merged 8 commits into
mainfrom
fix/native-settings-env-tests

Conversation

@aram356

@aram356 aram356 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Native cargo test -p trusted-server-core --lib fails 11 settings env override tests on main since Report deployed git version in x-ts-version #1213. The core build script exports TRUSTED_SERVER__GIT_VERSION with cargo:rustc-env, and Cargo also sets that variable on every cargo test run of the crate. The test-only Settings::from_toml_and_env loader reads every TRUSTED_SERVER__ variable as a settings override, so it deserializes an unknown git_version field and fails with Failed to deserialize configuration.
  • CI missed it because it runs the core unit tests only on wasm32-wasip1 under Viceroy, which does not pass the host environment to the guest. The only native core run in CI is --test template_build_digest.
  • The loader now skips that build input. Runtime loading is unaffected, because the EdgeZero env overlay only overrides keys that already exist in the config.

Changes

File Change
crates/trusted-server-core/src/settings.rs from_toml_and_env reads overrides from a copy of the environment without TRUSTED_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-axum
  • cargo clippy-fastly && cargo clippy-axum
  • cargo fmt --all -- --check
  • JS tests: cd crates/trusted-server-js/lib && npx vitest run
  • JS format: cd crates/trusted-server-js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve
  • Other: native cargo test -p trusted-server-core --target aarch64-apple-darwin --lib went from 11 failures to 2939 passed. The new test fails under Viceroy at the first commit with Failed to deserialize configuration and passes at the second. cargo test-cloudflare and cargo clippy-cloudflare also pass.

Checklist

  • Changes follow AGENTS.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses tracing macros (not println!)
  • New code has tests
  • No secrets or credentials committed

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.
@aram356 aram356 self-assigned this Oct 14, 2026
@aram356 aram356 added this to the 202610 milestone Oct 14, 2026

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Focused fix to exclude the build-time TRUSTED_SERVER__GIT_VERSION from test environment overrides, with regression coverage for the deserialization failure.

aram356 added a commit that referenced this pull request Oct 15, 2026

@dhruv8sh dhruv8sh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 config matching — see inline at crates/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-core unit tests only on wasm32-wasip1 under 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 native cargo test -p trusted-server-core --lib job (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

Comment thread crates/trusted-server-core/src/settings.rs
Comment thread crates/trusted-server-core/src/settings.rs Outdated
Comment thread crates/trusted-server-core/src/settings.rs
Comment thread crates/trusted-server-core/src/settings.rs
aram356 added a commit that referenced this pull request Oct 21, 2026
@aram356
aram356 merged commit f928191 into main Oct 22, 2026
23 checks passed
@aram356
aram356 deleted the fix/native-settings-env-tests branch October 22, 2026 03:31
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.

Native core settings tests fail because the build-time git version leaks into env overrides

4 participants