Hmbown/CodeWhale · error · anyhow::Error

DeepSeek Harness credentials line

Error message

DeepSeek Harness credentials line {} is invalid: {reason}

What it means

parse_dsh_deepseek_api_key parses a YAML-like DeepSeek Harness credentials file line by line. Each `key: value` pair's value must be a valid unquoted YAML string; when unquote_yaml_string fails, the error wraps the reason with the 1-based line number. It lets the user pinpoint exactly which credentials line is malformed.

Solutions

  1. Open the credentials file at the reported line number and fix the quoting of the value.
  2. Use plain unquoted or double-quoted ASCII values for the API key fields.
  3. Regenerate the credentials file rather than hand-editing it.

Example fix

// before (credentials file, line 3)
api_key: "sk-abc'
// after
api_key: "sk-abc"
Defensive patterns

Strategy: validation

Validate before calling

for (i, line) in credentials.lines().enumerate() {
    if let Some((_, value)) = line.split_once(': ') {
        if !(value.starts_with('"') && value.ends_with('"')) && value.contains(['\'', '"']) {
            eprintln!("line {} has mixed/broken quotes", i + 1);
        }
    }
}

Try / catch

match deepseek_api_key_from_grant(text) {
    Err(e) if e.to_string().contains("credentials line") => {
        let line = e.to_string();
        eprintln!("Fix the DeepSeek credentials file: {line}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: A credentials file line whose value part fails YAML string unquoting (e.g. malformed quote escaping, stray characters) passed through deepseek_api_key_from_grant.

Common situations: Hand-edited credentials file with broken quotes around the API key; copy-paste introducing smart quotes or trailing characters; mixed quote styles like `key: "value'`.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/fe53f80c06c4ec1f. Report an issue: GitHub.

Appendix: source

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

        }
        let Some((key, value)) = line.split_once(':') else {
            bail!(
                "DeepSeek Harness credentials line {} is not `KEY: value`",
                index + 1
            );
        };
        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 {

View on GitHub (pinned to 73e0f67d83)