Hmbown/CodeWhale · error · anyhow::Error

DeepSeek Harness credentials line {} has an empty value

Error message

DeepSeek Harness credentials line {} has an empty value

What it means

Thrown by parse_dsh_deepseek_api_key when a line's value, after trimming and YAML-style unquoting (unquote_yaml_string), is empty. Even an explicitly quoted empty string ("") fails: every declared key must map to a non-empty value, and the error names the 1-based line number.

Source

Thrown at crates/tui/src/dsh_credentials.rs:63

        };
        let key = key.trim();
        if !is_posix_identifier(key) {
            bail!(
                "DeepSeek Harness credentials line {} has a non-identifier key",
                index + 1
            );
        }
        if !seen.insert(key.to_string()) {
            bail!("DeepSeek Harness credentials declare `{key}` more than once");
        }
        let value = unquote_yaml_string(value.trim()).map_err(|reason| {
            anyhow::anyhow!(
                "DeepSeek Harness credentials line {} is invalid: {reason}",
                index + 1
            )
        })?;
        if value.is_empty() {
            bail!(
                "DeepSeek Harness credentials line {} has an empty value",
                index + 1
            );
        }
        if key == DEEPSEEK_API_KEY_REF {
            found = Some(value);
        }
    }
    Ok(found)
}

fn is_posix_identifier(value: &str) -> bool {
    let mut chars = value.chars();
    matches!(chars.next(), Some('A'..='Z' | 'a'..='z' | '_'))
        && chars.all(|ch| matches!(ch, 'A'..='Z' | 'a'..='z' | '0'..='9' | '_'))
}

fn unquote_yaml_string(value: &str) -> Result<String, &'static str> {

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Fill in a real value for the key on the reported line
  2. Remove the empty-valued line entirely if the key is not needed
  3. After rotating a key, replace the old value rather than clearing it

Example fix

# before
DEEPSEEK_API_KEY:

# after
DEEPSEEK_API_KEY: sk-live-abc123
Defensive patterns

Strategy: validation

Validate before calling

for (index, raw) in text.lines().enumerate() {
    let line = raw.trim();
    if line.is_empty() || line.starts_with('#') { continue; }
    let Some((_, value)) = line.split_once(':') else { continue; };
    if value.trim().is_empty() || matches!(value.trim(), "\"\"" | "''") {
        return Err(anyhow::anyhow!("line {}: value is empty; fill it or remove the line", index + 1));
    }
}

Prevention

When it happens

Trigger: Lines like "DEEPSEEK_API_KEY:" with nothing after the colon, or "DEEPSEEK_API_KEY: \"\"" / "DEEPSEEK_API_KEY: ''".

Common situations: Templates with placeholder keys never filled in; a rotation script blanking a revoked key instead of removing the line.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/b19486848ef7200c. Report an issue: GitHub.