nikivdev/code · error

sessions requires a specific provider (claude or codex)

Error message

sessions requires a specific provider (claude or codex)

What it means

provider_sessions in src/ai.rs:5345 rejects the generic Provider::All value because the sessions subcommand can only list sessions for one concrete provider. Listing across all providers is unsupported, so passing the aggregate provider selection bails immediately before any session files are read.

Source

Thrown at src/ai.rs:5345

                "",
                line,
                index_width = index_width,
                updated_width = updated_width,
                id_width = id_width,
            );
        }
    }

    println!();
    for hint in provider_session_listing_hints(provider, target, &rows, &display_ids) {
        println!("{hint}");
    }
    Ok(())
}

fn provider_sessions(provider: Provider, path: Option<String>, json: bool) -> Result<()> {
    if provider == Provider::All {
        bail!("sessions requires a specific provider (claude or codex)");
    }
    if provider == Provider::Codex {
        let target = resolve_session_target_path(path.as_deref())?;
        let sessions = read_sessions_for_target(provider, path.as_deref())?;
        return print_provider_session_listing(provider, &target, &sessions, json);
    }

    ensure_provider_tty(provider, "sessions")?;

    let launched = match provider {
        Provider::Claude => launch_claude_resume_picker()?,
        Provider::Codex => launch_codex_resume_picker()?,
        Provider::Cursor => false,
        Provider::All => false,
    };

    if launched {
        Ok(())

View on GitHub (pinned to a747e741ae)

Solutions

  1. Specify the provider explicitly: `f ai claude sessions` or `f ai codex sessions`
  2. If scripting, default the provider variable to "claude" or "codex" instead of "all"
  3. Check argument parsing/aliases that may drop the provider token

Example fix

// before
$ f ai sessions
// after
$ f ai codex sessions
Defensive patterns

Strategy: validation

Validate before calling

if provider == "all" || provider.is_empty() {
    eprintln!("sessions requires a provider: `f ai claude sessions` or `f ai codex sessions`");
    std::process::exit(2);
}

Type guard

fn is_concrete_provider(p: &str) -> bool {
    matches!(p, "claude" | "codex")
}

Try / catch

match run_sessions(provider) {
    Err(e) if e.to_string().contains("requires a specific provider") => {
        eprintln!("{e} — pass claude or codex explicitly");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Invoking the `sessions` subcommand without narrowing the provider so that Provider::All reaches provider_sessions — e.g. a bare `f ai sessions` or CLI wiring that defaults to All instead of claude/codex.

Common situations: Forgetting the provider argument when typing the command; shell alias or script that omits the provider; misconfigured CLI parser defaulting the provider to All.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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