nikivdev/code · error

No PR found for current branch and commit queue is empty.

Error message

No PR found for current branch and commit queue is empty.

What it means

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.

Source

Thrown at src/commit.rs:9645

            if !opts.no_open {
                let _ = open_in_browser(&url);
            }
            return Ok(());
        }
    }

    // Fallback: open based on queued commit (by explicit hash, by HEAD SHA, or latest entry).
    let hash = if let Some(hash) = opts.hash.clone() {
        hash
    } else {
        let head_sha = git_capture_in(repo_root, &["rev-parse", "HEAD"])
            .unwrap_or_default()
            .trim()
            .to_string();
        let _ = refresh_commit_queue(repo_root);
        let mut entries = load_commit_queue_entries(repo_root)?;
        if entries.is_empty() {
            bail!("No PR found for current branch and commit queue is empty.");
        }
        if !head_sha.is_empty() {
            if let Some(entry) = entries.iter().rev().find(|e| e.commit_sha == head_sha) {
                entry.commit_sha.clone()
            } else {
                entries.pop().unwrap().commit_sha
            }
        } else {
            entries.pop().unwrap().commit_sha
        }
    };

    // Reuse the commit queue PR-open behavior (creates draft if missing).
    run_commit_queue(CommitQueueCommand {
        action: Some(CommitQueueAction::PrOpen {
            hash,
            base: opts.base.clone(),
        }),

View on GitHub (pinned to a747e741ae)

Solutions

  1. Create the PR first (e.g. `f pr create` or push the branch) so one is found for the current branch.
  2. Queue a commit with `f commit --queue` before running.
  3. Pass an explicit `--hash <sha>` to bypass PR/queue resolution.
  4. Verify the branch name and repo root are what you expect.

Example fix

// before
f pr push        # no PR, queue empty
// after
f pr create
f pr push        # or: f pr push --hash <sha>
Defensive patterns

Strategy: fallback

Validate before calling

let has_pr = pr_for_current_branch().is_some();
let queue_empty = load_commit_queue_entries(repo_root).map(|q| q.is_empty()).unwrap_or(true);
if !has_pr && queue_empty { eprintln!("Nothing to operate on: create a PR or queue a commit"); }

Try / catch

match run() {
    Err(e) if e.to_string().contains("No PR found") => create_pr_or_queue_then_retry(),
    other => other,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/d02eba963f20a16a. Report an issue: GitHub.