{"record":{"id":"5104d635557d69fd","repo":"clockworklabs/SpacetimeDB","slug":"invalid-json5-string","errorCode":null,"errorMessage":"Invalid JSON5 string","messagePattern":"Invalid JSON5 string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/spacetime_config/environment.rs","lineNumber":71,"sourceCode":"                {\n                    i += content[i..].chars().next().unwrap().len_utf8();\n                }\n                if i == start {\n                    i += content[i..].chars().next().unwrap().len_utf8();\n                }\n                let token = &content[start..i];\n                if (token.starts_with(|c: char| c.is_ascii_digit() || matches!(c, '-' | '+' | '.'))\n                    || matches!(token, \"Infinity\" | \"NaN\"))\n                    && !content[i..].trim_start_matches(is_space).starts_with(':')\n                {\n                    replacements.push((start, i));\n                    numbers.push(token);\n                    continue;\n                }\n            }\n        }\n        if matches!(bytes[start], b'\\'' | b'\"') {\n            strings.push(json5::from_str(&content[start..i]).map_err(|_| anyhow::anyhow!(\"Invalid JSON5 string\"))?);\n        }\n    }\n    // Check decoded strings as well: Unicode escapes must not manufacture an\n    // internal marker and cause a string to be interpreted as a number.\n    let mut prefix = \"__spacetime_numeric_\".to_owned();\n    while content.contains(&prefix) || strings.iter().any(|s| s.contains(&prefix)) {\n        prefix.push('_');\n    }\n    let mut text = String::with_capacity(content.len());\n    let mut previous = 0;\n    for (index, (start, end)) in replacements.into_iter().enumerate() {\n        text.push_str(&content[previous..start]);\n        text.push_str(&format!(\"\\\"{prefix}{index}\\\"\"));\n        previous = end;\n    }\n    text.push_str(&content[previous..]);\n    // Parser diagnostics may quote the source line, which can contain secrets.\n    let mut value: Value = json5::from_str(&text).map_err(|_| anyhow::anyhow!(\"Invalid JSON5 configuration\"))?;","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/spacetime_config/environment.rs#L53-L89","documentation":"The environment config parser pre-scans quoted regions of a JSON5 file and decodes each quoted token with `json5::from_str`. If a quoted span is not a valid JSON5 string (e.g. an unterminated or malformed quote), parsing of the whole config fails with this generic error to avoid leaking secret-bearing diagnostics.","triggerScenarios":"A config file contains an unterminated or malformed quoted string, such as a missing closing quote or an invalid escape sequence inside a value.","commonSituations":"Hand-editing config with secrets; pasting values with unmatched quotes; apostrophes in passwords that clash with JSON5 single-quote delimiters.","solutions":["Check the config file for unterminated or improperly escaped quoted strings.","Escape internal quotes (\\\" or \\') and backslashes in values.","Validate the JSON5 config with a local JSON5 parser before publishing."],"exampleFix":"// before (config)\nPASSWORD: 'it's secret\n// after (config)\nPASSWORD: \"it's secret\"","handlingStrategy":"validation","validationCode":"// validate quotes in the config before running the CLI\nconst json5 = require('json5');\ntry { json5.parse(fs.readFileSync(configPath, 'utf8')); } catch (e) { console.error('Malformed quoted string in config:', e.message); }","typeGuard":null,"tryCatchPattern":"match result { Err(e) if e.to_string() == \"Invalid JSON5 string\" => { eprintln!(\"Check unterminated quotes/escapes in config\"); }, Err(e) => return Err(e), Ok(v) => v }","preventionTips":["Escape internal quotes and backslashes inside config values.","Prefer double-quoted JSON strings for values containing apostrophes.","Run a JSON5 validator locally before publishing secret-bearing configs."],"tags":["config","json5","parse-error"],"backgroundTag":"json-parse-error","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"}