{"record":{"id":"936c4bfe3c149471","repo":"risingwavelabs/risingwave","slug":"failed-to-parse-path-file-path-content-cont","errorCode":null,"errorMessage":"failed to parse, path: {file_path}, content: {content}, error: {e}","messagePattern":"failed to parse, path: (.+?), content: (.+?), error: (.+?)","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"warning","filePath":"src/utils/resource_util/src/lib.rs","lineNumber":378,"sourceCode":"        match fs_err::read_to_string(file_path) {\n            Ok(controller_string) => {\n                for controller in controller_string.split_whitespace() {\n                    if controller.eq(controller_name) {\n                        return true;\n                    };\n                }\n                false\n            }\n            Err(_) => false,\n        }\n    }\n\n    pub fn parse_error(\n        file_path: &str,\n        content: &str,\n        e: impl std::fmt::Display,\n    ) -> std::io::Error {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            format!(\"failed to parse, path: {file_path}, content: {content}, error: {e}\"),\n        )\n    }\n\n    /// Reads an integer value from a file path.\n    pub fn read_usize(file_path: &str) -> Result<usize, std::io::Error> {\n        let content = fs_err::read_to_string(file_path)?;\n        let limit_val = content\n            .trim()\n            .parse::<usize>()\n            .map_err(|e| parse_error(file_path, &content, e))?;\n        Ok(limit_val)\n    }\n\n    /// Helper function that helps to retrieve value in file, if value is \"max\", `max_value` will be\n    /// returned instead.\n    pub fn read_usize_or_max(file_path: &str, max_value: usize) -> Result<usize, std::io::Error> {","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/utils/resource_util/src/lib.rs#L360-L396","documentation":"`parse_error` is a helper that wraps any parse failure of a cgroup interface file into `io::Error(InvalidData)` with the file path, raw content, and underlying error in the message, to make cgroup-limit debugging diagnosable.","triggerScenarios":"Any of `get_cpu_limit_v2`, `read_usize`, `read_usize_or_max` reading a cgroup file whose content cannot be parsed into the expected integer(s).","commonSituations":"cgroup files containing 'max', empty content, or trailing garbage; wrong file paths containing human-readable text; nested-container layouts with unexpected values.","solutions":["Read the path from the error message and verify its content is parseable (e.g. integers or 'max').","Ensure the container exposes a proper cgroup v2 unified hierarchy.","Sanitize content (trim) and confirm no locale/exotic characters in the file.","Patch/fallback: treat unparseable limit as unlimited and log a warning."],"exampleFix":"// before\nlet v = read_usize(\"/sys/fs/cgroup/cpu.max\")?; // errors on \"max 100000\"\n// after: validate content first\nlet content = std::fs::read_to_string(\"/sys/fs/cgroup/cpu.max\")?;\nif content.split_whitespace().next() == Some(\"max\") { /* no limit */ } else { let v = read_usize(\"/sys/fs/cgroup/cpu.max\")?; }","handlingStrategy":"fallback","validationCode":"fn parseable_int(path: &str) -> bool {\n    std::fs::read_to_string(path).map(|c| c.trim().parse::<usize>().is_ok()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match read_usize(path) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => {\n        // e.to_string() includes path, content, and cause — log and fall back\n        fallback();\n    }\n    other => other?,\n}","preventionTips":["Validate cgroup file contents before parsing.","Treat 'max'/empty as unlimited rather than a parse error.","Pin known-good container runtimes with standard cgroup layouts."],"tags":["rust","cgroup","parse","diagnostics"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}