{"record":{"id":"9800f087a697a0fc","repo":"jlcodes99/cockpit-tools","slug":"json","errorCode":null,"errorMessage":"不支持的 JSON 格式 {:?}","messagePattern":"不支持的 JSON 格式 (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cockpit-core/src/modules/codex_account_core_mutations_quota.rs","lineNumber":73,"sourceCode":"                    candidates.push((tokens, hint, filename_label.clone()));\n                } else {\n                    logger::log_error(&format!(\"未找到有效 Token {:?}\", file_path));\n                }\n            }\n            serde_json::Value::Array(arr) => {\n                for item in arr {\n                    if let Some((tokens, hint)) = extract_codex_tokens_from_value(item) {\n                        let label = item\n                            .get(\"email\")\n                            .and_then(|v| v.as_str())\n                            .unwrap_or(&filename_label)\n                            .to_string();\n                        candidates.push((tokens, hint, label));\n                    }\n                }\n            }\n            _ => {\n                logger::log_error(&format!(\"不支持的 JSON 格式 {:?}\", file_path));\n            }\n        }\n\n        if candidates.len() == before_count {\n            logger::log_info(&format!(\n                \"Codex 文件旧规则未找到账号，将尝试 Token/JSON 导入逻辑 {:?}\",\n                file_path\n            ));\n            fallback_files.push((content, filename_label));\n        }\n    }\n\n    if candidates.is_empty() && fallback_files.is_empty() {\n        return Err(\n            \"未找到有效的 Codex Token（需要 accessToken/access_token、id_token + access_token，或 refresh_token）\"\n                .to_string(),\n        );\n    }","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/crates/cockpit-core/src/modules/codex_account_core_mutations_quota.rs#L55-L91","documentation":"import_from_files only supports JSON files whose top-level value is an object or an array of objects. When the parsed file is any other JSON type (string, number, boolean, or bare null), this error is logged and the file cannot be processed as a legacy-rule import. It signals a malformed or wrong-kind of input file, not a token problem.","triggerScenarios":"Calling import_from_files on a file whose content is e.g. a bare string, a number, or 'null' — typically a wrong file selected in the import dialog or a file that contains only a pasted token string without JSON object wrapping.","commonSituations":"User pastes a raw token into a .json file; drag-and-drop of the wrong file; a corrupted/truncated JSON file that parses to a scalar; exporting tool emitted a JSONL or quoted string.","solutions":["Ensure the file contains a JSON object (single account) or array of objects (multiple accounts)","Wrap a raw token in a JSON object like {\"access_token\": \"...\"} before importing","Re-export/re-download the auth file from the source tool","Check the file was not truncated or corrupted during transfer"],"exampleFix":"// before (token.txt saved as .json)\n\"eyJhbGciOi...\"\n// after\n{ \"access_token\": \"eyJhbGciOi...\" }","handlingStrategy":"validation","validationCode":"fn is_importable_shape(v: &serde_json::Value) -> bool {\n    match v {\n        serde_json::Value::Object(_) => true,\n        serde_json::Value::Array(a) => a.iter().all(|i| i.is_object()),\n        _ => false,\n    }\n}","typeGuard":"fn top_level_kind(v: &serde_json::Value) -> &'static str {\n    match v {\n        serde_json::Value::Object(_) => \"object\",\n        serde_json::Value::Array(_) => \"array\",\n        serde_json::Value::String(_) => \"string\",\n        serde_json::Value::Number(_) => \"number\",\n        serde_json::Value::Bool(_) => \"bool\",\n        serde_json::Value::Null => \"null\",\n    }\n}","tryCatchPattern":null,"preventionTips":["Never save a raw token string with a .json extension","Always export/import whole JSON objects or arrays of objects","Check file contents (first non-whitespace char should be '{' or '[') before import","Re-export the file if it may have been truncated"],"tags":["codex","import","json","validation"],"backgroundTag":"unsupported-json-format","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}