PR: #29 (feat/04-toml-config-loader)
File: crates/charon-core/src/config.rs, lines 93-109 (substitute_env_vars)
Substitution is string-level, not TOML-aware. If env var value contains ", \, newline, or TOML comment char #, the resulting document is malformed or mis-parsed. Example:
BNB_WS_URL=wss://host/path?token="secret"&foo
After substitution, the " closes the surrounding TOML string early, remainder becomes garbage. Loader reports parse error, not "invalid env value."
Additional gaps:
- No default-value syntax
${VAR:-default} — every var must be set even for optional fields.
- No
$$ escape for literal ${ in TOML content.
var_name not validated: ${} (empty) reads env var with empty name → always-error; ${WITH SPACE} lookup is quietly wrong.
Fix:
- Before substitution, escape env value: replace
\ → \\, " → \", newline → \n. Only when target context is a TOML string (detect by checking surrounding chars is complex — simplest: escape unconditionally, document that values go inside double-quoted TOML strings).
- Support
${VAR:-default}:
let (name, default) = match var_name.split_once(":-") { ... };
- Validate
var_name is non-empty and matches [A-Z_][A-Z0-9_]*.
- Document escape rule in
substitute_env_vars rustdoc.
PR: #29 (feat/04-toml-config-loader)
File: crates/charon-core/src/config.rs, lines 93-109 (substitute_env_vars)
Substitution is string-level, not TOML-aware. If env var value contains
",\, newline, or TOML comment char#, the resulting document is malformed or mis-parsed. Example:After substitution, the
"closes the surrounding TOML string early, remainder becomes garbage. Loader reports parse error, not "invalid env value."Additional gaps:
${VAR:-default}— every var must be set even for optional fields.$$escape for literal${in TOML content.var_namenot validated:${}(empty) reads env var with empty name → always-error;${WITH SPACE}lookup is quietly wrong.Fix:
\→\\,"→\", newline →\n. Only when target context is a TOML string (detect by checking surrounding chars is complex — simplest: escape unconditionally, document that values go inside double-quoted TOML strings).${VAR:-default}:var_nameis non-empty and matches[A-Z_][A-Z0-9_]*.substitute_env_varsrustdoc.