{"record":{"id":"025a03c5f6acce10","repo":"rust-lang/rust-analyzer","slug":"invalid-profile-depth","errorCode":null,"errorMessage":"invalid profile depth","messagePattern":"invalid profile depth","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rust-analyzer/src/tracing/hprof.rs","lineNumber":243,"sourceCode":"\n#[derive(Default, Clone, Debug)]\npub(crate) struct WriteFilter {\n    depth: usize,\n    longer_than: Duration,\n}\n\nimpl WriteFilter {\n    pub(crate) fn from_spec(mut spec: &str) -> (WriteFilter, Option<FxHashSet<String>>) {\n        let longer_than = if let Some(idx) = spec.rfind('>') {\n            let longer_than = spec[idx + 1..].parse().expect(\"invalid profile longer_than\");\n            spec = &spec[..idx];\n            Duration::from_millis(longer_than)\n        } else {\n            Duration::new(0, 0)\n        };\n\n        let depth = if let Some(idx) = spec.rfind('@') {\n            let depth: usize = spec[idx + 1..].parse().expect(\"invalid profile depth\");\n            spec = &spec[..idx];\n            depth\n        } else {\n            999\n        };\n        let allowed = if spec == \"*\" {\n            None\n        } else {\n            Some(FxHashSet::from_iter(spec.split('|').map(String::from)))\n        };\n        (WriteFilter { depth, longer_than }, allowed)\n    }\n}\n\n#[allow(non_camel_case_types)]\nstruct ms(Duration);\n\nimpl std::fmt::Display for ms {","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/rust-analyzer/src/tracing/hprof.rs#L225-L261","documentation":"The hprof WriteFilter spec parser expects an optional '@N' suffix giving maximum profiling depth, parsed as usize. If the text after '@' is not a valid usize the expect panics with 'invalid profile depth'. Like the longer_than check, this is upfront validation of the profiling filter string.","triggerScenarios":"Passing a profiling spec such as 'profile@x' or 'profile@' (empty after '@'), or a value exceeding usize range (e.g. '@99999999999999999999999'), through the profiling env/config.","commonSituations":"Typos in the depth portion of RA_PROFILE; shell interpolation replacing the number with empty or garbage; docs confusion between spec sections ('@' for depth vs '>' for duration).","solutions":["Fix the spec so the '@' suffix is a valid depth integer, e.g. 'profile@3' limits depth to 3.","Remove the '@' suffix entirely to use the default depth of 999.","Check the env var for shell-quoting/interpolation issues that corrupt the value."],"exampleFix":"// before\nRA_PROFILE=\"load@\"          // empty depth\n// after\nRA_PROFILE=\"load@5\"         // depth 5, or omit '@' for default","handlingStrategy":"validation","validationCode":"fn validate_profile_depth(spec: &str) -> Result<(), String> {\n    if let Some(idx) = spec.rfind('@') {\n        spec[idx + 1..].parse::<usize>()\n            .map(|_| ())\n            .map_err(|_| format!(\"invalid depth suffix in {spec:?}\"))\n    } else { Ok(()) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use integer depths only after '@' (e.g. @3)","Omit the '@' section to accept the default depth of 999","Validate env values before launching rust-analyzer in scripts"],"tags":["rust-analyzer","tracing","profiling","parsing"],"backgroundTag":"profiling-spec-parse-error","analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}