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:
config crate delivers env vars as JsonValue::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-changed can't track integration env vars because Settings::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 the config crate 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 every cargo build, with conditional file write to avoid unnecessary recompilation
- Split
from_toml / from_toml_and_env: Runtime path uses fast toml::from_str(); build-time path uses config crate for env var merging
- Trailing slash validation: Replaced
Publisher::normalize() with #[validate] on origin_url
References
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
configcrate delivers env vars asJsonValue::String. When serialized to TOML and deserialized back, values like"true"stay as strings instead of becoming bools.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)
IntegrationSettings::normalize()converts string values to native types before TOML serializationcargo:rerun-if-changed=_always_rebuild_sentinel_forces rebuild on everycargo build, with conditional file write to avoid unnecessary recompilationfrom_toml/from_toml_and_env: Runtime path uses fasttoml::from_str(); build-time path usesconfigcrate for env var mergingPublisher::normalize()with#[validate]onorigin_urlReferences