{"record":{"id":"db05df3a97dbe824","repo":"Hmbown/CodeWhale","slug":"deepseek-harness-credentials-declare-key-more","errorCode":null,"errorMessage":"DeepSeek Harness credentials declare `{key}` more than once","messagePattern":"DeepSeek Harness credentials declare `(.+?)` more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/dsh_credentials.rs","lineNumber":54,"sourceCode":"        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\n            )\n        })?;\n        if value.is_empty() {\n            bail!(\n                \"DeepSeek Harness credentials line {} has an empty value\",\n                index + 1\n            );\n        }\n        if key == DEEPSEEK_API_KEY_REF {\n            found = Some(value);\n        }\n    }\n    Ok(found)","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/dsh_credentials.rs#L36-L72","documentation":"`parse_dsh_deepseek_api_key` inserts each parsed key into a `seen` set and bails if the key was already present, rejecting duplicate declarations. Duplicate keys make the document ambiguous, so parsing stops rather than picking one silently.","triggerScenarios":"A dsh credentials document declaring the same key twice, e.g. two `DEEPSEEK_API_KEY:` lines (possibly with different values) anywhere in the file.","commonSituations":"Appending a new key without removing the old line; merging two credentials files; copy-paste duplication during manual editing.","solutions":["Open the credentials document and delete the older duplicate line, keeping one authoritative value per key.","Search the file for repeated key names (`grep -n 'DEEPSEEK_API_KEY'`) and deduplicate.","If merging files, union the keys instead of concatenating the contents."],"exampleFix":"// before\nDEEPSEEK_API_KEY: sk-old\nDEEPSEEK_API_KEY: sk-new\n// after\nDEEPSEEK_API_KEY: sk-new","handlingStrategy":"validation","validationCode":"// detect duplicate keys before import\nlet mut seen = std::collections::HashSet::new();\nfor (i, line) in text.lines().enumerate() {\n    if let Some((k, _)) = line.trim().split_once(':') {\n        let k = k.trim();\n        assert!(seen.insert(k.to_string()), \"duplicate key `{k}` at line {}\", i + 1);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When merging credentials files, deduplicate keys instead of concatenating.","Replace old values in place rather than appending new lines for the same key.","Grep for the key name before adding it to confirm it is not already declared."],"tags":["deepseek","credentials","duplicate-key","parsing"],"backgroundTag":"conflicting-config-options","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"}