Skip to main content

materialise_kv_namespace_id

Function materialise_kv_namespace_id 

Source
pub fn materialise_kv_namespace_id(
    text: &str,
    id: &str,
) -> Result<String, String>
Expand description

Materialise the deploy-time KV namespace id placeholder in a generated wrangler.toml’s text, structurally. Parses text and, if (and only if) the first [[kv_namespaces]] entry’s id is currently exactly KV_NAMESPACE_ID_PLACEHOLDER, replaces it with id.

Any other state — no [[kv_namespaces]] section at all, or an id that’s already been materialised to a real value — is a no-op, returning text unchanged (byte-for-byte: the document is never re-serialised in this branch, so there’s nothing for a caller to mistakenly treat as a real write). This mirrors the exact gate the old text.contains(KV_NAMESPACE_ID_PLACEHOLDER) check enforced; it is not a general “always overwrite with the given id” operation. Widening it into a re-provisioning operation is a different feature, out of scope here (#1305’s own Decision B).