{"record":{"id":"34d3c89df3c91924","repo":"nikivdev/code","slug":"selection-out-of-range","errorCode":null,"errorMessage":"Selection out of range.","messagePattern":"Selection out of range\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/agents.rs","lineNumber":277,"sourceCode":"    println!(\"Select an agents profile:\");\n    for (index, profile) in profiles.iter().enumerate() {\n        println!(\"  {}) {}\", index + 1, profile);\n    }\n    print!(\"choice> \");\n    io::stdout().flush()?;\n\n    let stdin = io::stdin();\n    let line = stdin.lock().lines().next();\n    let input = match line {\n        Some(Ok(value)) => value.trim().to_string(),\n        _ => \"\".to_string(),\n    };\n    if input.is_empty() {\n        bail!(\"No profile selected.\");\n    }\n    let idx: usize = input.parse().context(\"invalid selection\")?;\n    if idx == 0 || idx > profiles.len() {\n        bail!(\"Selection out of range.\");\n    }\n    Ok(profiles[idx - 1].clone())\n}\n\nstruct AgentEntry {\n    name: String,\n    display: String,\n    path: Option<PathBuf>,\n}\n\nstruct FzfAgentResult<'a> {\n    entry: &'a AgentEntry,\n    with_args: bool,\n}\n\nfn run_fuzzy_agents() -> Result<()> {\n    let entries = build_agent_entries()?;\n    if entries.is_empty() {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/agents.rs#L259-L295","documentation":"run_flow_agent_capture (public API in src/agents.rs) runs the flow agent and captures final text. It requires the external `gen` tool directly — find_gen() is called unconditionally (no claude/opencode fallback here) — and bails with the install-message if gen is not found.","triggerScenarios":"Any programmatic call to flow::agents::run_flow_agent_capture(prompt) on a machine where the gen repo/binary cannot be located (not installed, GEN_REPO unset or wrong).","commonSituations":"Embedding flow as a library on a new machine without the gen dependency; CI jobs that install flow but not gen; GEN_REPO pointing to a stale path after a repo move.","solutions":["Install gen: cd <gen_repo_hint> && f install.","Set GEN_REPO env var to the local gen repo checkout before calling the API.","In library code, validate find_gen()-equivalent availability up front and surface a friendly setup error."],"exampleFix":"// before\nlet out = agents::run_flow_agent_capture(prompt)?; // panics-path: gen not found\n// after\n+ if std::env::var(\"GEN_REPO\").is_err() {\n+     std::env::set_var(\"GEN_REPO\", \"/home/user/src/gen\");\n+ }\nlet out = agents::run_flow_agent_capture(prompt)?;","handlingStrategy":"try-catch","validationCode":"std::env::var(\"GEN_REPO\").map_err(|_| \"set GEN_REPO before calling run_flow_agent_capture\")?;","typeGuard":null,"tryCatchPattern":"match agents::run_flow_agent_capture(prompt) {\n    Err(e) if e.to_string().contains(\"gen not found\") => {\n        eprintln!(\"setup: cd <gen repo> && f install, or export GEN_REPO\");\n        String::new() // or a fallback path\n    }\n    Ok(text) => text,\n}","preventionTips":["Pre-flight check gen availability in library hosts before agent calls.","Document the gen/GEN_REPO dependency wherever this API is used.","Install gen as part of environment bootstrap scripts."],"tags":["missing-binary","gen","public-api","environment-variable"],"backgroundTag":"required-executable-not-on-path","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}