{"record":{"id":"47829d072533138b","repo":"rust-lang/rust","slug":"failed-to-parse-version","errorCode":null,"errorMessage":"failed to parse version","messagePattern":"failed to parse version","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/tools/bump-stage0/src/main.rs","lineNumber":39,"sourceCode":"}\n\nimpl Tool {\n    fn new(compiler_date: Option<String>, rustfmt_date: Option<String>) -> Result<Self, Error> {\n        let channel = match std::fs::read_to_string(\"src/ci/channel\")?.trim() {\n            \"stable\" => Channel::Stable,\n            \"beta\" => Channel::Beta,\n            \"nightly\" => Channel::Nightly,\n            other => anyhow::bail!(\"unsupported channel: {}\", other),\n        };\n\n        // Split \"1.42.0\" into [1, 42, 0]\n        let version = std::fs::read_to_string(\"src/version\")?\n            .trim()\n            .split('.')\n            .map(|val| val.parse())\n            .collect::<Result<Vec<_>, _>>()?\n            .try_into()\n            .map_err(|_| anyhow::anyhow!(\"failed to parse version\"))?;\n\n        let existing = parse_stage0_file();\n\n        Ok(Self {\n            channel,\n            version,\n            compiler_date,\n            rustfmt_date,\n            config: existing.config,\n            checksums: IndexMap::new(),\n        })\n    }\n\n    fn update_stage0_file(mut self) -> Result<(), Error> {\n        const COMMENTS: &str = r#\"# The configuration above this comment is editable, and can be changed\n# by forks of the repository if they have alternate values.\n#\n# The section below is generated by `./x.py run src/tools/bump-stage0`,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/tools/bump-stage0/src/main.rs#L21-L57","documentation":"Thrown by Tool::new in bump-stage0 when src/version cannot be parsed into exactly three u16 components. The file is read, trimmed, split on '.', each part parsed as u16, and the result collected into a [u16; 3] array via try_into. Failure means either the wrong number of components or a non-numeric component.","triggerScenarios":"src/version contains fewer or more than three dot-separated numbers (e.g. '1.82' or '1.82.0.0'); a component is non-numeric or empty; a component exceeds the u16 max (65535).","commonSituations":"Editing src/version during a release and leaving an incomplete value; accidental newline or whitespace inside a component; tooling wrote a pre-release suffix (e.g. '1.82.0-dev') that the parser does not handle.","solutions":["Open src/version and confirm it is exactly MAJOR.MINOR.PATCH with three numeric components (e.g. 1.82.0).","Ensure no trailing newline/whitespace inside components and no extra dot-separated fields.","Confirm each number is within 0..=65535."],"exampleFix":"// before\n$ cat src/version\n1.82\n\n// after\n$ echo 1.82.0 > src/version","handlingStrategy":"validation","validationCode":"// Validate the version string shape before parsing.\nlet raw = std::fs::read_to_string(\"src/version\")?.trim().to_string();\nlet parts: Vec<&str> = raw.split('.').collect();\nif parts.len() != 3 || parts.iter().any(|p| p.parse::<u16>().is_err()) {\n    eprintln!(\"src/version '{raw}' is not MAJOR.MINOR.PATCH with numeric u16 parts\");\n    std::process::exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep src/version as exactly three numeric dot-separated components.","Avoid pre-release suffixes in this file; bump-stage0 does not parse them.","Validate the file in CI when editing release metadata."],"tags":["bump-stage0","configuration","parsing","version"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}