{"record":{"id":"fc620e14a9982fda","repo":"Hmbown/CodeWhale","slug":"gitee-pull-request-create-failed-http-status","errorCode":null,"errorMessage":"Gitee pull request create failed (HTTP {status}).","messagePattern":"Gitee pull request create failed \\(HTTP (.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/dispatch_runner.rs","lineNumber":648,"sourceCode":"        .connect_timeout(std::time::Duration::from_secs(8))\n        .timeout(std::time::Duration::from_secs(30))\n        .redirect(reqwest::redirect::Policy::none())\n        .build()\n        .context(\"could not initialize the Gitee client\")?\n        .post(url)\n        .form(&[\n            (\"access_token\", token.as_str()),\n            (\"title\", title),\n            (\"head\", job.branch.as_str()),\n            (\"base\", patch.base_branch.as_str()),\n            (\"body\", body),\n        ])\n        .send()\n        .context(\"could not reach Gitee\")?;\n    let status = response.status();\n    let text = response.text().unwrap_or_default();\n    if !status.is_success() {\n        bail!(\"Gitee pull request create failed (HTTP {status}).\");\n    }\n    let parsed: serde_json::Value =\n        serde_json::from_str(&text).context(\"Gitee returned invalid JSON\")?;\n    parsed\n        .get(\"html_url\")\n        .and_then(serde_json::Value::as_str)\n        .map(str::trim)\n        .filter(|url| url.starts_with(\"https://\"))\n        .map(|url| url.to_string())\n        .ok_or_else(|| anyhow!(\"Gitee did not report a pull request URL; refusing to invent one.\"))\n}\n\nfn open_pr_cnb(\n    slug: &str,\n    job: &CloudJob,\n    patch: &PatchReceipt,\n    title: &str,\n    body: &str,","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/dispatch_runner.rs#L630-L666","documentation":"`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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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).","Verify the head and base branches exist on Gitee and that commits were actually pushed before creating the PR.","Confirm the slug (owner/repo) matches the current Gitee repository name.","Retry after a delay if the status is 429 or 5xx (rate limit or Gitee-side outage)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: confirm token and branches\ncurl -s -o /dev/null -w \"%{http_code}\" -H \"Authorization: Bearer $GITEE_TOKEN\" https://gitee.com/api/v5/repos/$OWNER/$REPO\nlet _ = (head_exists, base_exists); // both must be true before calling open","typeGuard":null,"tryCatchPattern":"match dispatch_result {\n    Err(e) if e.to_string().contains(\"Gitee pull request create failed\") => {\n        // inspect HTTP status in message; refresh token / fix branches, then retry with backoff for 429/5xx\n    }\n    other => other?,\n}","preventionTips":["Refresh the Gitee token before long-running automation and grant repo write scope.","Push branches and verify they exist on the remote before creating PRs.","Handle 429 with exponential backoff instead of immediate retries."],"tags":["gitee","http","pull-request","api"],"backgroundTag":"http-error-response","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}