{"record":{"id":"f2dcd7a5a2d4119a","repo":"astral-sh/ruff","slug":"could-not-find-any-tasks-matching-the-given-criter","errorCode":null,"errorMessage":"could not find any tasks matching the given criteria","messagePattern":"could not find any tasks matching the given criteria","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_completion_eval/src/main.rs","lineNumber":183,"sourceCode":"\n    let sources = TaskSource::all(&truth)?;\n    match args.command {\n        Command::ShowOne(ref cmd) => {\n            tmp_eval_dir.disable_cleanup(cmd.keep_tmp_dir);\n\n            let Some(source) = sources\n                .iter()\n                .find(|source| cmd.matches_source_task(source))\n            else {\n                anyhow::bail!(\"could not find task named `{}`\", cmd.task_name);\n            };\n            let tasks = source.to_tasks(&tmp_eval_path)?;\n            let matching: Vec<&Task> = tasks.iter().filter(|task| cmd.matches_task(task)).collect();\n            anyhow::ensure!(\n                !matching.is_empty(),\n                \"could not find any tasks matching the given criteria\",\n            );\n            anyhow::ensure!(\n                matching.len() < 2,\n                \"found more than one task matching the given criteria\",\n            );\n            let task = &matching[0];\n            let completions = task.completions()?;\n\n            let mut stdout = std::io::stdout().lock();\n            for (i, c) in completions.iter().enumerate() {\n                write!(stdout, \"{}\", c.name.as_str())?;\n                if let Some(module_name) = c.module_name {\n                    write!(stdout, \" (module: {module_name})\")?;\n                }\n                if task.cursor.answer.matches(c) {\n                    write!(stdout, \" (*, {}/{})\", i + 1, completions.len())?;\n                }\n                writeln!(stdout)?;\n            }\n            writeln!(stdout, \"-----\")?;","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/astral-sh/ruff/blob/5bb508f59481c1a02d5c7ff8568b9ffd8a763eef/crates/ty_completion_eval/src/main.rs#L165-L201","documentation":"After selecting a source and expanding it to tasks, the evaluator asserts exactly one task matches the given criteria; an empty match set triggers this `anyhow::ensure!` failure. It means the filters (`matches_task`) selected nothing.","triggerScenarios":"Running `show-one` with criteria (fixture, file name, index, task name) that no generated task satisfies, e.g. a cursor index or file name that doesn't exist in the fixture's expansion.","commonSituations":"Passing a wrong `--file-name` for the fixture; a cursor `--index` beyond the file's cursors; task names/criteria edited after fixtures changed.","solutions":["Verify the file name and cursor index exist in the fixture (count `<CURSOR:...>` directives and files)","Correct the task name/criteria to match the fixture's defined task","Run without restrictive criteria to enumerate the tasks, then pick valid ones"],"exampleFix":"# before\nty_completion_eval show-one pandas --file-name complet.py --index 9\n// after\nty_completion_eval show-one pandas --file-name completion.py --index 2","handlingStrategy":"validation","validationCode":"import re, sys\nfixture, fname, idx = sys.argv[1], sys.argv[3], int(sys.argv[5])\ntext = open(f'crates/ty_python_semantic/resources/mdtest/{fixture}.md').read()\ncursors = [m.start() for m in re.finditer(r'<CURSOR:', text)]\nif idx >= len(cursors):\n    sys.exit(f\"fixture has only {len(cursors)} cursors; --index must be smaller\")","typeGuard":null,"tryCatchPattern":"match show_one(...) {\n    Err(e) if e.to_string().contains(\"could not find any tasks matching\") => {\n        eprintln!(\"No task matched; verify --file-name and --index against the fixture\");\n    }\n    result => result,\n}","preventionTips":["Confirm the file name exists in the fixture before passing --file-name","Count `<CURSOR:` directives in the mdtest and use a 0-based index within range","Run the broader `-- all` evaluation first to see valid task/file/index combinations"],"tags":["cli","task-selection","empty-result"],"backgroundTag":"no-matching-task","analyzedSha":"5bb508f59481c1a02d5c7ff8568b9ffd8a763eef","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}