{"record":{"id":"da60319f6480e9c1","repo":"astral-sh/ruff","slug":"unable-to-parse-filename","errorCode":null,"errorMessage":"Unable to parse filename","messagePattern":"Unable to parse filename","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/settings/types.rs","lineNumber":867,"sourceCode":"\n    pub(crate) fn is_empty(&self) -> bool {\n        self.inner.is_empty()\n    }\n}\n\nimpl<T: std::fmt::Debug> CompiledPerFileList<T> {\n    /// Return an iterator over the entries in `self` that match the input `path`.\n    ///\n    /// `debug_label` is used for [`debug!`] messages explaining why certain patterns were matched.\n    pub(crate) fn iter_matches<'a, 'p>(\n        &'a self,\n        path: &'p Path,\n        debug_label: &'static str,\n    ) -> impl Iterator<Item = &'p T>\n    where\n        'a: 'p,\n    {\n        let file_name = path.file_name().expect(\"Unable to parse filename\");\n        let basename = Candidate::new(file_name);\n        let absolute = Candidate::new(path);\n        self.inner.iter().filter_map(move |entry| {\n            if entry.basename_matcher.is_match_candidate(&basename) {\n                if entry.negated {\n                    None\n                } else {\n                    debug!(\n                        \"{} for {:?} due to basename match on {:?}: {:?}\",\n                        debug_label,\n                        path,\n                        entry.basename_matcher.glob().regex(),\n                        entry.data\n                    );\n                    Some(&entry.data)\n                }\n            } else if entry.absolute_matcher.is_match_candidate(&absolute) {\n                if entry.negated {","sourceCodeStart":849,"sourceCodeEnd":885,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_linter/src/settings/types.rs#L849-L885","documentation":"This is a panic guard on Path::file_name: the code calls path.file_name().expect(...) while matching a file against per-file exclusion patterns, and file_name() returns None only when the path terminates in '..' or is otherwise a nameless terminus (e.g. an empty path or a root-relative path with no file component). In practice every file discovered by the linter has a file name, so this sentinel expect fires only for malformed or synthesized paths reaching iter_matches without a final component.","triggerScenarios":"Thrown at crates/ruff_linter/src/settings/types.rs:867 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure any programmatically constructed or canonicalized path passed to exclusion matching (e.g. via match_exclusion in add_noqa.rs or analyze_graph.rs) retains a final file component and is not '..', empty, or root-only","Filter out or skip paths where path.file_name() returns None before passing them to iter_matches, instead of relying on the expect to panic","If handling nameless paths is required, replace the expect with a graceful fallback such as treating a missing file name as a non-match for exclusion patterns"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}