{"record":{"id":"386102874f888bf2","repo":"Hmbown/CodeWhale","slug":"deepseek-harness-credentials-line-is-not-key","errorCode":null,"errorMessage":"DeepSeek Harness credentials line {} is not `KEY: value`","messagePattern":"DeepSeek Harness credentials line (.+?) is not `KEY: value`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/dsh_credentials.rs","lineNumber":41,"sourceCode":"    let Some(text) = crate::external_credentials::read_to_string(grant)? else {\n        return Ok(None);\n    };\n    parse_dsh_deepseek_api_key(&text)\n}\n\n/// Strict subset of dsh-credentials-local: a mapping of POSIX identifiers to\n/// non-empty strings. Nested values, empty strings, and duplicate keys fail\n/// closed. Only `DEEPSEEK_API_KEY` is returned.\npub(crate) fn parse_dsh_deepseek_api_key(text: &str) -> Result<Option<String>> {\n    let mut found = None;\n    let mut seen = std::collections::BTreeSet::new();\n    for (index, raw) in text.lines().enumerate() {\n        let line = raw.trim();\n        if line.is_empty() || line.starts_with('#') {\n            continue;\n        }\n        let Some((key, value)) = line.split_once(':') else {\n            bail!(\n                \"DeepSeek Harness credentials line {} is not `KEY: value`\",\n                index + 1\n            );\n        };\n        let key = key.trim();\n        if !is_posix_identifier(key) {\n            bail!(\n                \"DeepSeek Harness credentials line {} has a non-identifier key\",\n                index + 1\n            );\n        }\n        if !seen.insert(key.to_string()) {\n            bail!(\"DeepSeek Harness credentials declare `{key}` more than once\");\n        }\n        let value = unquote_yaml_string(value.trim()).map_err(|reason| {\n            anyhow::anyhow!(\n                \"DeepSeek Harness credentials line {} is invalid: {reason}\",\n                index + 1","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/dsh_credentials.rs#L23-L59","documentation":"`parse_dsh_deepseek_api_key` parses a dsh credentials document line by line, skipping blanks and `#` comments. Every other line must be `KEY: value`; a line with no colon aborts parsing with the 1-based line number. The document format is enforced strictly so keys can be trusted downstream.","triggerScenarios":"A dsh credentials file/grant document containing a non-empty, non-comment line without a `:` separator — e.g. a stray token, YAML list item (`- foo` without value colon), or prose accidentally saved into the credentials file.","commonSituations":"Hand-edited credentials file with a typo; pasted text including a header or note line; an exported file from another tool with a different format (JSON/YAML block style) fed into the dsh parser.","solutions":["Open the credentials document at the reported line number and reformat the line as `KEY: value`.","Remove stray non-credential lines (notes, headers) or prefix them with `#` to make them comments.","If the file came from another tool, re-export it in the dsh `KEY: value` format instead of converting by hand."],"exampleFix":"// credentials file before (line 3 bad)\nDEEPSEEK_API_KEY: sk-abc\nsome stray text\n// after\nDEEPSEEK_API_KEY: sk-abc\n# some stray text","handlingStrategy":"validation","validationCode":"// validate the credentials document before import\ntext.lines()\n    .enumerate()\n    .filter(|(_, l)| { let l = l.trim(); !l.is_empty() && !l.starts_with('#') })\n    .for_each(|(i, l)| assert!(l.contains(':'), \"line {} lacks KEY: value\", i + 1));","typeGuard":null,"tryCatchPattern":"match import_dsh_credentials() {\n    Err(e) if e.to_string().contains(\"is not `KEY: value`\") => {\n        // open the file at the reported line and fix formatting, then retry\n    }\n    other => other?,\n}","preventionTips":["Edit dsh credentials files only in `KEY: value` form; mark notes as `#` comments.","Do not paste JSON/YAML exports from other tools into the dsh credentials file.","Lint the file (line contains `:`) after every manual edit."],"tags":["deepseek","credentials","parsing","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}