Skip to main content

expand_env_placeholders_strict

Function expand_env_placeholders_strict 

Source
pub fn expand_env_placeholders_strict(input: &str) -> Result<String>
Expand description

Expand ${VAR} and ${VAR:-default} placeholders, failing when a placeholder resolves to nothing.

A value that cannot be expanded is a configuration error, not a literal: letting ${UAR_MEMORY_MCP_URL:-http://…} reach a URL parser verbatim turns a missing setting into a confusing downstream parse failure.

§Errors

Returns an error naming every placeholder that had neither a non-empty environment variable nor a :- default.

§Examples

// Unset and no default — a startup error rather than a literal.
assert!(expand_env_placeholders_strict("${UAR_DOC_UNSET_VAR}").is_err());