{"record":{"id":"805b8ca9cb02ebd3","repo":"clockworklabs/SpacetimeDB","slug":"unknown-field-field","errorCode":null,"errorMessage":"unknown field `{field}`","messagePattern":"unknown field `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/spacetime_config/environment.rs","lineNumber":113,"sourceCode":"/// receive visit_u128 from Value's deserializer. That buffer cannot represent\n/// u128, while the arbitrary-precision JSON parser preserves its decimal token.\n/// Diagnostics discard values while retaining a bounded, ordinary unknown field\n/// name, which is useful for correcting misspelled configuration options.\npub(super) fn decode_config(value: Value) -> anyhow::Result<super::SpacetimeConfig> {\n    let encoded = serde_json::to_vec(&value).map_err(|_| anyhow::anyhow!(\"Invalid configuration structure\"))?;\n    serde_json::from_slice(&encoded).map_err(|error| {\n        let diagnostic = error.to_string();\n        if let Some((field, suffix)) = diagnostic\n            .strip_prefix(\"unknown field `\")\n            .and_then(|message| message.split_once('`'))\n            && suffix.starts_with(\", expected \")\n            && !field.is_empty()\n            && field.len() <= 64\n            && field\n                .bytes()\n                .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-'))\n        {\n            return anyhow::anyhow!(\"unknown field `{field}`\");\n        }\n        anyhow::anyhow!(\"Invalid configuration structure\")\n    })\n}\n\nfn is_space(ch: char) -> bool {\n    ch.is_whitespace() || ch == '\\u{feff}'\n}\n\nfn restore(value: &mut Value, prefix: &str, numbers: &[&str], env_key: Option<&str>) -> anyhow::Result<()> {\n    match value {\n        Value::String(s) => {\n            if let Some(index) = s.strip_prefix(prefix).and_then(|s| s.parse::<usize>().ok()) {\n                let token = numbers[index];\n                *value = if let Some(env_key) = env_key {\n                    Value::Number(token.parse().map_err(|_| {\n                        anyhow::anyhow!(\n                            \"Environment key {:?}: numeric config input must use JSON number syntax\",","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/spacetime_config/environment.rs#L95-L131","documentation":"When the SpacetimeConfig deserializer reports an unknown field, `decode_config` re-raises it as `unknown field \\`{field}\\`` — but only if the field name is a safe, bounded, ordinary identifier (non-empty, ≤64 chars, alphanumeric/underscore/dash). This gives actionable misspelling feedback without exposing secret values.","triggerScenarios":"A typo'd or unsupported key in the spacetimedb config file, e.g. `envrionment:` instead of `environment:`, provided the key passes the safe-name filter.","commonSituations":"Misspelling top-level config keys; using keys from an older/newer CLI version that no longer exist; copying config examples from outdated docs.","solutions":["Correct the field name to one supported by your CLI version (`spacetime --help` or docs).","Remove obsolete fields no longer recognized by the current CLI.","Check for typos — the error names the exact offending field."],"exampleFix":"// before (config)\nenvrionment: { KEY: \"v\" }\n// after (config)\nenvironment: { KEY: \"v\" }","handlingStrategy":"validation","validationCode":"const KNOWN = ['environment','database','server','project'];\nfor (const key of Object.keys(topLevelConfig)) if (!KNOWN.includes(key)) console.warn('unknown config field:', key);","typeGuard":"fn is_known_config_field(key: &str, known: &[&str]) -> bool { known.contains(&key) }","tryCatchPattern":"match result { Err(e) if e.to_string().starts_with(\"unknown field\") => { let f = /* parse field from message */; eprintln!(\"Fix or remove config key: {f}\"); }, Err(e) => return Err(e), Ok(v) => v }","preventionTips":["Check field names against docs for your CLI version before editing.","Beware renamed config keys across CLI upgrades — read release notes.","Keep a known-good config template in the repo."],"tags":["config","validation","unknown-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-09-20T12:15:59.611Z","contentChangedAt":"2026-09-20T12:15:59.611Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}