{"record":{"id":"9a9ba2b6a5b8d215","repo":"gitbutlerapp/gitbutler","slug":"bitbucket-does-not-support-reopening-a-declined-pu","errorCode":null,"errorMessage":"Bitbucket does not support reopening a declined pull request via the API.","messagePattern":"Bitbucket does not support reopening a declined pull request via the API\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-forge/src/review.rs","lineNumber":2473,"sourceCode":"            // a `state` field. Map the forge-agnostic ReviewState onto that.\n            let state_event = state.as_ref().map(|s| s.as_gitlab_state_event());\n            let params = but_gitlab::UpdateMergeRequestParams {\n                project_id,\n                mr_iid,\n                title: title.as_deref(),\n                description: body.as_deref(),\n                target_branch: target_base.as_deref(),\n                state_event,\n            };\n            but_gitlab::mr::update(preferred_account, params, storage).await?;\n            Ok(())\n        }\n        ForgeName::Bitbucket => {\n            let preferred_account = preferred_forge_user\n                .as_ref()\n                .and_then(|user| user.bitbucket());\n            if matches!(state, Some(ReviewState::Open)) {\n                return Err(anyhow::anyhow!(\n                    \"Bitbucket does not support reopening a declined pull request via the API.\"\n                ));\n            }\n            if title.is_some() || body.is_some() || target_base.is_some() {\n                let id = review_number\n                    .try_into()\n                    .context(\"PR: Failed to cast usize to i64, somehow\")?;\n                let params = but_bitbucket::UpdatePullRequestParams {\n                    workspace: owner,\n                    repo_slug: repo,\n                    id,\n                    title: title.as_deref(),\n                    description: body.as_deref(),\n                    target_branch: target_base.as_deref(),\n                };\n                but_bitbucket::pr::update(preferred_account, params, storage).await?;\n            }\n            if matches!(state, Some(ReviewState::Closed)) {","sourceCodeStart":2455,"sourceCodeEnd":2491,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-forge/src/review.rs#L2455-L2491","documentation":"Bitbucket's REST API has no endpoint to reopen a pull request that has been declined; GitButler therefore rejects the operation up front instead of sending a doomed request. This is a deliberate guard in `update_review`'s Bitbucket arm when the requested state transition is to `Open`.","triggerScenarios":"Calling `update_review` with `ForgeName::Bitbucket` and `state: Some(ReviewState::Open)` on a PR that was declined/closed.","commonSituations":"Trying to reuse a declined Bitbucket PR after new commits; migrating a GitHub workflow (where reopen works) to Bitbucket; scripted state synchronization that unconditionally sets Open.","solutions":["Create a new pull request instead of reopening the declined one.","Guard the caller: only request `ReviewState::Open` for forges that support reopening (GitHub/GitLab).","On Bitbucket, if the PR was declined by mistake, ask a reviewer with permission via the Bitbucket web UI — but note the API itself cannot do it.","Skip the state change and update only title/body/target if those are what you needed."],"exampleFix":"// before\nupdate_review(..., ForgeName::Bitbucket, Some(ReviewState::Open), ...).await?;\n\n// after\nif forge == ForgeName::Bitbucket && state == Some(ReviewState::Open) {\n    // declined Bitbucket PRs cannot be reopened via API; open a new PR instead\n    create_review(...).await?;\n} else {\n    update_review(..., forge, state, ...).await?;\n}","handlingStrategy":"validation","validationCode":"fn can_reopen(forge: ForgeName) -> bool { !matches!(forge, ForgeName::Bitbucket) }\nif state == Some(ReviewState::Open) && !can_reopen(forge) {\n    // create a new PR instead\n}","typeGuard":null,"tryCatchPattern":"match update_review(..., ForgeName::Bitbucket, Some(ReviewState::Open), ...) {\n    Err(e) if e.to_string().contains(\"does not support reopening\") => create_review(...).await?,\n    other => other?,\n}","preventionTips":["Never request ReviewState::Open transitions for declined Bitbucket PRs","Model forge capabilities in your caller code before issuing state changes","Prefer creating a replacement PR for declined Bitbucket reviews"],"tags":["bitbucket","pull-request","unsupported-operation","api-limitation"],"backgroundTag":"unsupported-operation","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}