{"record":{"id":"d02eba963f20a16a","repo":"nikivdev/code","slug":"no-pr-found-for-current-branch-and-commit-queue-is","errorCode":null,"errorMessage":"No PR found for current branch and commit queue is empty.","messagePattern":"No PR found for current branch and commit queue is empty\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":9645,"sourceCode":"            if !opts.no_open {\n                let _ = open_in_browser(&url);\n            }\n            return Ok(());\n        }\n    }\n\n    // Fallback: open based on queued commit (by explicit hash, by HEAD SHA, or latest entry).\n    let hash = if let Some(hash) = opts.hash.clone() {\n        hash\n    } else {\n        let head_sha = git_capture_in(repo_root, &[\"rev-parse\", \"HEAD\"])\n            .unwrap_or_default()\n            .trim()\n            .to_string();\n        let _ = refresh_commit_queue(repo_root);\n        let mut entries = load_commit_queue_entries(repo_root)?;\n        if entries.is_empty() {\n            bail!(\"No PR found for current branch and commit queue is empty.\");\n        }\n        if !head_sha.is_empty() {\n            if let Some(entry) = entries.iter().rev().find(|e| e.commit_sha == head_sha) {\n                entry.commit_sha.clone()\n            } else {\n                entries.pop().unwrap().commit_sha\n            }\n        } else {\n            entries.pop().unwrap().commit_sha\n        }\n    };\n\n    // Reuse the commit queue PR-open behavior (creates draft if missing).\n    run_commit_queue(CommitQueueCommand {\n        action: Some(CommitQueueAction::PrOpen {\n            hash,\n            base: opts.base.clone(),\n        }),","sourceCodeStart":9627,"sourceCodeEnd":9663,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L9627-L9663","documentation":"When resolving which commit to operate on, the flow first tries to find an open PR for the current branch; if none is found, it falls back to the commit queue. If the queue is also empty, it bails because there is no PR and no queued commit to act on. The fallback prefers a queue entry matching the current HEAD SHA, otherwise the latest entry.","triggerScenarios":"Running the command on a branch with no associated (open) PR while `load_commit_queue_entries` returns an empty list; queue already consumed; queue file missing or in a different repo root.","commonSituations":"Working on a branch never pushed/never had a PR created; running from a worktree or different checkout where the queue file is absent; a previous run already popped the queue.","solutions":["Create the PR first (e.g. `f pr create` or push the branch) so one is found for the current branch.","Queue a commit with `f commit --queue` before running.","Pass an explicit `--hash <sha>` to bypass PR/queue resolution.","Verify the branch name and repo root are what you expect."],"exampleFix":"// before\nf pr push        # no PR, queue empty\n// after\nf pr create\nf pr push        # or: f pr push --hash <sha>","handlingStrategy":"fallback","validationCode":"let has_pr = pr_for_current_branch().is_some();\nlet queue_empty = load_commit_queue_entries(repo_root).map(|q| q.is_empty()).unwrap_or(true);\nif !has_pr && queue_empty { eprintln!(\"Nothing to operate on: create a PR or queue a commit\"); }","typeGuard":null,"tryCatchPattern":"match run() {\n    Err(e) if e.to_string().contains(\"No PR found\") => create_pr_or_queue_then_retry(),\n    other => other,\n}","preventionTips":["Create/push the PR for the branch before running PR commands.","Queue a commit as a fallback before invoking.","Verify the current branch name matches the PR's branch.","Pass `--hash` to skip PR/queue resolution."],"tags":["git","pull-request","queue","empty-state"],"backgroundTag":"queue-empty","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}