-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Summary
Environment variables set via TRUSTED_SERVER__INTEGRATIONS__* lose their types when roundtripped through the build.rs → TOML → runtime pipeline. String values like "true" and "123" are not converted back to their expected bool/number types, causing runtime deserialization failures.
Root Cause
- Type loss in TOML roundtrip:
configcrate delivers env vars asJsonValue::String. When serialized to TOML and deserialized back, values like"true"stay as strings instead of becoming bools. - Build.rs doesn't detect env var changes:
cargo:rerun-if-env-changedcan't track integration env vars becauseSettings::default()has an empty HashMap — the keys aren't known ahead of time. from_toml()redundantly scanned env vars at runtime: The old implementation re-ran theconfigcrate pipeline on every call, even though the embedded TOML already contains the final resolved values.
Fix (PR #362)
- Eager type normalization:
IntegrationSettings::normalize()converts string values to native types before TOML serialization - Always-rerun sentinel:
cargo:rerun-if-changed=_always_rebuild_sentinel_forces rebuild on everycargo build, with conditional file write to avoid unnecessary recompilation - Split
from_toml/from_toml_and_env: Runtime path uses fasttoml::from_str(); build-time path usesconfigcrate for env var merging - Trailing slash validation: Replaced
Publisher::normalize()with#[validate]onorigin_url
References
- PR Fix env var config roundtrip through build.rs TOML serialization #362: Fix env var config roundtrip through build.rs TOML serialization #362
- Related: PR Optimize Settings::from_toml() call #350 (from_toml optimization analysis)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels