{"record":{"id":"b5b76cdbe098b232","repo":"denisidoro/navi","slug":"no-files-found","errorCode":null,"errorMessage":"No files found","messagePattern":"No files found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/commands/core/actor.rs","lineNumber":223,"sourceCode":"\npub fn act(\n    extractions: Result<(&str, Item)>,\n    files: Vec<String>,\n    variables: Option<VariableMap>,\n) -> Result<()> {\n    let (\n        key,\n        Item {\n            tags,\n            comment,\n            snippet,\n            file_index,\n            ..\n        },\n    ) = extractions.unwrap();\n\n    if key == \"ctrl-o\" {\n        edit::edit_file(Path::new(&files[file_index.expect(\"No files found\")]))\n            .expect(\"Could not open file in external editor\");\n        return Ok(());\n    }\n\n    env_var::set(env_var::PREVIEW_INITIAL_SNIPPET, &snippet);\n    env_var::set(env_var::PREVIEW_TAGS, &tags);\n    env_var::set(env_var::PREVIEW_COMMENT, comment);\n\n    let interpolated_snippet = {\n        let mut s = replace_variables_from_snippet(\n            &snippet,\n            &tags,\n            variables.expect(\"No variables received from finder\"),\n        )\n        .context(\"Failed to replace variables from snippet\")?;\n        s = with_absolute_path(s);\n        s = deser::with_new_lines(s);\n        s","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/denisidoro/navi/blob/f7330b9ad5bd95b7d1a3c96d00e0a77deb589147/src/commands/core/actor.rs#L205-L241","documentation":"Raised in `act` in src/commands/core/actor.rs (src/commands/core/actor.rs:223) via `file_index.expect(\"No files found\")` when the user presses ctrl-o to open a file in an external editor, but the extracted `file_index` is None — meaning the finder selection did not resolve to any file in the `files` list.","triggerScenarios":"Pressing ctrl-o in the interactive UI when the current selection has no associated file index — e.g. the matched entry came from a command that produced no file paths, or the results list was empty/out of sync with `files`.","commonSituations":"Running a snippet whose output lines are not file paths and then pressing ctrl-o; stale selection after the file list was re-filtered; invoking the action on a preview/comment-only entry.","solutions":["Only press ctrl-o when the selected entry corresponds to an actual file path","Ensure the underlying command outputs valid file paths so the file index can be populated","Re-select an entry after filtering so the index matches the current file list","Report/patch the panic path: return a proper error instead of `expect` when file_index is None"],"exampleFix":"// before\nedit::edit_file(Path::new(&files[file_index.expect(\"No files found\")]))\n// after\nmatch file_index {\n    Some(i) => edit::edit_file(Path::new(&files[i]))?,\n    None => anyhow::bail!(\"No files found\"),\n}","handlingStrategy":"type-guard","validationCode":"// wrap the action: only allow ctrl-o when a file is actually selected\nlet can_open = selection_is_file && file_index.is_some();\nif !can_open { eprintln!(\"No file selected; ctrl-o requires a file entry\"); }","typeGuard":"fn has_file_index(idx: &Option<usize>) -> bool { idx.is_some() }","tryCatchPattern":"// if you wrap the binary/process: treat a panic on ctrl-o as \"no file selected\"\n// and re-run with a plain file-producing snippet\nlet status = child.wait()?;\nif !status.success() && stderr.contains(\"No files found\") {\n    eprintln!(\"Selection was not a file; choose a file-backed entry.\");\n}","preventionTips":["Only trigger ctrl-o on entries produced by file-listing commands","Re-select after filtering so the index matches the visible list","Ensure snippets output real file paths one per line"],"tags":["panic","missing-file","interactive"],"backgroundTag":"missing-selection-index","analyzedSha":"f7330b9ad5bd95b7d1a3c96d00e0a77deb589147","analyzedAt":"2026-09-03T13:58:22.429Z","contentChangedAt":"2026-09-03T13:58:22.429Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}