Hmbown/CodeWhale · error · anyhow::Error

a Gitee access token is not configured in the Codewhale…

Error message

a Gitee access token is not configured in the Codewhale service slot; the branch was pushed but no pull request was opened

What it means

open_pr_gitee requires a Gitee access token read from the Codewhale service token slot; when read_service_token("gitee") returns None it fails with this error. The message explicitly states the branch push already succeeded — only the PR-open step could not proceed.

Solutions

  1. Store a Gitee personal access token in the Codewhale service slot under the 'gitee' key, then retry the PR step.
  2. Verify the token exists by listing/reading Codewhale service tokens for 'gitee'.
  3. If the branch is already on Gitee, open the PR manually in the Gitee web UI using the pushed branch.

Example fix

# before
$ codewhale service-token list   # no gitee entry
# after
$ codewhale service-token set gitee <personal-access-token>
Defensive patterns

Strategy: validation

Validate before calling

if read_service_token("gitee").is_none() {
    eprintln!("configure a Gitee token in the Codewhale service slot before dispatching Gitee PR jobs");
}

Try / catch

match open_pr_gitee(slug, job, patch, title, body) {
    Err(e) if e.to_string().contains("not configured in the Codewhale service slot") => {
        // branch was pushed; prompt user to set the token, then open PR manually
    }
    other => other?,
}

Prevention

When it happens

Trigger: open -> open_pr_gitee on a Gitee forge job while no 'gitee' token is stored in the Codewhale service slot (never configured, stored under a different key, or the secret service returned nothing).

Common situations: Fresh setup where credentials were never configured; token stored under a different service name; keyring/secret service unavailable so lookup returns None; token revoked and deleted.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/dispatch_runner.rs:626

            sanitize_error(&String::from_utf8_lossy(&output.stderr))
        );
    }
    let url = String::from_utf8_lossy(&output.stdout).trim().to_string();
    if !url.starts_with("https://") {
        bail!("gh did not report a pull request URL; refusing to invent one.");
    }
    Ok(url)
}

fn open_pr_gitee(
    slug: &str,
    job: &CloudJob,
    patch: &PatchReceipt,
    title: &str,
    body: &str,
) -> Result<String> {
    let token = read_service_token("gitee").ok_or_else(|| {
        anyhow!("a Gitee access token is not configured in the Codewhale service slot; the branch was pushed but no pull request was opened")
    })?;
    let url = validate_outbound_origin(&gitee_pr_url(slug))?;
    let response = crate::tls::reqwest_blocking_client_builder()
        .connect_timeout(std::time::Duration::from_secs(8))
        .timeout(std::time::Duration::from_secs(30))
        .redirect(reqwest::redirect::Policy::none())
        .build()
        .context("could not initialize the Gitee client")?
        .post(url)
        .form(&[
            ("access_token", token.as_str()),
            ("title", title),
            ("head", job.branch.as_str()),
            ("base", patch.base_branch.as_str()),
            ("body", body),
        ])
        .send()
        .context("could not reach Gitee")?;

View on GitHub (pinned to 73e0f67d83)