Hmbown/CodeWhale · error

Gitee pull request create failed

Error message

Gitee pull request create failed (HTTP {status}).

What it means

`open_pr_gitee` POSTs a pull-request-create request to the Gitee API; when the HTTP response status is not a success (2xx) it bails with the returned status code. The response body text is read but only used for later JSON parsing of `html_url`, so the status is the sole failure signal.

Solutions

  1. Read the response body/status from the log and fix the reported cause (most often 401/403: refresh the Gitee token and grant repo write scope).
  2. Verify the head and base branches exist on Gitee and that commits were actually pushed before creating the PR.
  3. Confirm the slug (owner/repo) matches the current Gitee repository name.
  4. Retry after a delay if the status is 429 or 5xx (rate limit or Gitee-side outage).
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: confirm token and branches
curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer $GITEE_TOKEN" https://gitee.com/api/v5/repos/$OWNER/$REPO
let _ = (head_exists, base_exists); // both must be true before calling open

Try / catch

match dispatch_result {
    Err(e) if e.to_string().contains("Gitee pull request create failed") => {
        // inspect HTTP status in message; refresh token / fix branches, then retry with backoff for 429/5xx
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `open` with the Gitee provider while the Gitee API responds 4xx/5xx to the PR-create POST (bad token, missing scopes, invalid branch/slug, rate limit, server error).

Common situations: Expired or scope-limited Gitee access token; head or base branch name does not exist; slug/owner mismatch after repo rename; Gitee rate limiting or 5xx outage.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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

Appendix: source

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

        .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")?;
    let status = response.status();
    let text = response.text().unwrap_or_default();
    if !status.is_success() {
        bail!("Gitee pull request create failed (HTTP {status}).");
    }
    let parsed: serde_json::Value =
        serde_json::from_str(&text).context("Gitee returned invalid JSON")?;
    parsed
        .get("html_url")
        .and_then(serde_json::Value::as_str)
        .map(str::trim)
        .filter(|url| url.starts_with("https://"))
        .map(|url| url.to_string())
        .ok_or_else(|| anyhow!("Gitee did not report a pull request URL; refusing to invent one."))
}

fn open_pr_cnb(
    slug: &str,
    job: &CloudJob,
    patch: &PatchReceipt,
    title: &str,
    body: &str,

View on GitHub (pinned to 73e0f67d83)