{"record":{"id":"d28ea6adae860192","repo":"epi052/feroxbuster","slug":"no-path-segments-found","errorCode":null,"errorMessage":"No path segments found","messagePattern":"No path segments found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/url.rs","lineNumber":272,"sourceCode":"    ///\n    /// Essentially looks at the Url path and determines how many directories are present in the\n    /// given Url\n    ///\n    /// http://localhost -> 1\n    /// http://localhost/ -> 1\n    /// http://localhost/stuff -> 2\n    /// ...\n    ///\n    /// returns 0 on error and relative urls\n    pub fn depth(&self) -> Result<usize> {\n        log::trace!(\"enter: get_depth\");\n\n        let target = self.normalize();\n\n        let parsed = parse_url_with_raw_path(&target)?;\n        let parts = parsed\n            .path_segments()\n            .ok_or_else(|| anyhow!(\"No path segments found\"))?;\n\n        // at least an empty string returned by the Split, meaning top-level urls\n        let mut depth = 0;\n\n        for _ in parts {\n            depth += 1;\n        }\n\n        log::trace!(\"exit: get_depth -> {depth}\");\n        Ok(depth)\n    }\n}\n\n/// Display implementation for a FeroxUrl\nimpl fmt::Display for FeroxUrl {\n    /// formatter for FeroxUrl\n    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n        write!(f, \"{}\", self.target)","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/epi052/feroxbuster/blob/1f595dab5c76858d5a14fbc47dabf2563d729c62/src/url.rs#L254-L290","documentation":"FeroxUrl::depth computes a target's path depth by splitting its path into segments. After parsing with parse_url_with_raw_path it calls path_segments(); since that returns None for URLs without a hierarchical path component (cannot-be-a-base URLs), the code bails with 'No path segments found'.","triggerScenarios":"Calling .depth() on a URL that url::Url parses as cannot-be-a-base — opaque URLs like 'mailto:a@b' or 'data:text/plain,hi' have no path segments and trigger the error; normal http(s) URLs (even empty paths) yield segments.","commonSituations":"Feeding non-HTTP schemes (mailto:, data:) into scan-url handling or recursion-depth checks via a target list containing such entries.","solutions":["Use an http/https URL with a normal path when calling depth()","Filter non-hierarchical schemes out of the target list before computing depth","Handle the anyhow error at the call site (ordered_scan_url / reached_max_depth) and skip the offending URL"],"exampleFix":"// before\nlet d = FeroxUrl::new(\"mailto:user@example.com\", 1)?.depth()?;\n// after\nif url.starts_with(\"http\") { let d = ferox_url.depth()?; }","handlingStrategy":"type-guard","validationCode":"fn has_path_segments(u: &url::Url) -> bool { u.path_segments().map(|_| true).unwrap_or(false) }","typeGuard":"fn is_hierarchical_http(s: &str) -> bool { url::Url::parse(s).ok().map(|u| matches!(u.scheme(), \"http\"|\"https\") && u.path_segments().is_some()).unwrap_or(false) }","tryCatchPattern":"match ferox_url.depth() { Err(e) if e.to_string().contains(\"No path segments\") => skip_url(url), Err(e) => return Err(e), Ok(d) => use_depth(d) }","preventionTips":["Only compute depth for http/https URLs","Filter opaque schemes (mailto:, data:) out of target lists","Wrap depth() in error handling that skips unsuitable targets"],"tags":["url","path","depth"],"backgroundTag":"invalid-url-format","analyzedSha":"1f595dab5c76858d5a14fbc47dabf2563d729c62","analyzedAt":"2026-09-13T19:33:06.208Z","contentChangedAt":"2026-09-13T19:33:06.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}