{"record":{"id":"28385b507f3ea9d6","repo":"BigPizzaV3/CodexPlusPlus","slug":"user-script-runtime-status-must-be-a-json-object","errorCode":null,"errorMessage":"user-script runtime status must be a JSON object","messagePattern":"user-script runtime status must be a JSON object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/user_scripts.rs","lineNumber":42,"sourceCode":"        \"(() => JSON.stringify(window.__codexPlusUserScripts?.scripts || {}))()\",\n    )\n    .await?;\n    parse_live_runtime_status_response(&response)\n}\n\nfn live_runtime_target(targets: &[crate::cdp::CdpTarget]) -> anyhow::Result<crate::cdp::CdpTarget> {\n    crate::cdp::pick_injectable_codex_page_target(targets)\n}\n\nfn parse_live_runtime_status_response(response: &Value) -> anyhow::Result<Value> {\n    let encoded = response\n        .pointer(\"/result/result/value\")\n        .and_then(Value::as_str)\n        .context(\"user-script runtime probe returned no value\")?;\n    let status: Value =\n        serde_json::from_str(encoded).context(\"invalid user-script runtime status JSON\")?;\n    if !status.is_object() {\n        anyhow::bail!(\"user-script runtime status must be a JSON object\");\n    }\n    Ok(status)\n}\n\n#[derive(Debug, Clone, PartialEq, Eq, Serialize)]\npub struct UserScriptConfig {\n    pub enabled: bool,\n    pub scripts: BTreeMap<String, bool>,\n    #[serde(default, skip_serializing_if = \"BTreeMap::is_empty\")]\n    pub market: BTreeMap<String, MarketScriptInstall>,\n}\n\nimpl Default for UserScriptConfig {\n    fn default() -> Self {\n        Self {\n            enabled: true,\n            scripts: BTreeMap::new(),\n            market: BTreeMap::new(),","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/user_scripts.rs#L24-L60","documentation":"parse_live_runtime_status_response decodes the doubly-encoded JSON returned by the user-script runtime probe (at pointer /result/result/value) and expects the decoded status to be a JSON object. If the decoded value is any other JSON type (string, array, number, null), the runtime status cannot be mapped onto the expected status shape and the function bails.","triggerScenarios":"live_runtime_status receiving a probe result whose inner `value` parses to a non-object JSON — e.g. the runtime script returned a bare string, an error array, or `null`; wrong script version returning a wrapped status differently.","commonSituations":"Editing the user-script runtime entrypoint so it echoes a plain-text/stringified message instead of a status object; a failing runtime that returns a JSON array of errors; older runtime scripts predating the object status contract.","solutions":["Ensure the user-script runtime status probe returns a JSON object (e.g. `{\"running\":true,\"scripts\":[...]}`), not a scalar or array.","Check which script binary/entrypoint is registered as the runtime probe and update it to the current version.","Log the decoded `status` value before this call to see what shape is actually returned, then fix the producer side."],"exampleFix":"// before (runtime script output)\necho \"running\";\n// after\necho '{\"running\": true, \"scripts\": []}';","handlingStrategy":"type-guard","validationCode":"let raw: serde_json::Value = serde_json::from_str(encoded)?;\nif !raw.is_object() {\n    eprintln!(\"runtime probe returned non-object status: {raw}\");\n    return Ok(default_status());\n}","typeGuard":"fn status_object(v: &serde_json::Value) -> Option<&serde_json::Map<String, serde_json::Value>> {\n    v.as_object()\n}","tryCatchPattern":"match parse_live_runtime_status_response(&encoded) {\n    Ok(status) => render(status),\n    Err(e) if e.to_string().contains(\"must be a JSON object\") => render_runtime_unavailable(),\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the runtime status probe script in lockstep with the expected JSON schema.","Return structured JSON objects from the runtime even on failure (e.g. {\"running\": false, \"error\": \"...\"}).","Version the status schema and validate it in runtime script tests."],"tags":["json","validation","runtime","user-scripts"],"backgroundTag":"unexpected-response-shape","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}