{"record":{"id":"ae2ea904a1efd182","repo":"Hmbown/CodeWhale","slug":"a-cnb-access-token-is-not-configured-in-the-codewhale","errorCode":null,"errorMessage":"a CNB access token is not configured in the Codewhale service slot; the branch was pushed but no pull request was opened","messagePattern":"a CNB access token is not configured in the Codewhale service slot; the branch was pushed but no pull request was opened","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/dispatch_runner.rs","lineNumber":669,"sourceCode":"        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,\n) -> Result<String> {\n    let token = read_service_token(\"cnb\").ok_or_else(|| {\n        anyhow!(\"a CNB access token is not configured in the Codewhale service slot; the branch was pushed but no pull request was opened\")\n    })?;\n    let url = validate_outbound_origin(&cnb_pr_url(slug))?;\n    let response = crate::tls::reqwest_blocking_client_builder()\n        .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 CNB client\")?\n        .post(url)\n        .bearer_auth(&token)\n        .json(&serde_json::json!({\n            \"title\": title,\n            \"head\": job.branch,\n            \"base\": patch.base_branch,\n            \"body\": body,\n        }))\n        .send()\n        .context(\"could not reach CNB\")?;","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/dispatch_runner.rs#L651-L687","documentation":"open_pr_cnb in dispatch_runner.rs pushes a branch then opens a pull request on cnb.cool. Before making the HTTP call it reads the CNB access token from the Codewhale service slot via read_service_token; when the slot is empty it fails with this error. The message deliberately notes the branch was already pushed so the user knows remote state exists and only the PR step failed.","triggerScenarios":"Calling `open` on a cloud job with a CNB patch receipt when no `cnb` service token has been stored (read_service_token(\"cnb\") returns None).","commonSituations":"Fresh install where the CNB token was never provisioned into the service slot; token store reset or rotated away; running on a machine/container without the credentials mounted; typo in the slot name during setup.","solutions":["Provision the CNB access token into the Codewhale service slot (the `cnb` slot read by read_service_token), then re-run the open command.","Verify the token store location/permissions so the service slot is readable by the TUI process.","The branch is already pushed; after configuring the token, open the PR manually on cnb.cool or re-run only the PR step."],"exampleFix":"// before: CNB token missing\n$ codewhale open --job <id>\n// after: provision the token, then retry\n$ codewhale service set cnb --token <CNB_ACCESS_TOKEN>\n$ codewhale open --job <id>","handlingStrategy":"validation","validationCode":"if read_service_token(\"cnb\").is_none() {\n    eprintln!(\"CNB token missing; configure the service slot before opening a PR\");\n    return;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision the CNB token into the service slot during environment setup, not at first use.","Add a preflight check for required service tokens in scripts that push branches.","Document the token slot name (`cnb`) so setup does not guess."],"tags":["config","credentials","pull-request","cnb"],"backgroundTag":"missing-credentials","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"}