{"record":{"id":"47af10635327aba5","repo":"rust-lang/cargo","slug":"could-not-find-typos-version-in-workflow","errorCode":null,"errorMessage":"Could not find typos version in workflow","messagePattern":"Could not find typos version in workflow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/xtask-spellcheck/src/main.rs","lineNumber":130,"sourceCode":"}\n\nfn extract_workflow_typos_version(metadata: &Metadata) -> anyhow::Result<Version> {\n    let ws_root = metadata.workspace_root.as_path().as_std_path();\n    let workflow_path = ws_root.join(\".github\").join(\"workflows\").join(\"main.yml\");\n    let file_content = std::fs::read_to_string(workflow_path)?;\n\n    extract_typos_version_from_content(&file_content)\n}\n\nfn extract_typos_version_from_content(file_content: &str) -> anyhow::Result<Version> {\n    file_content\n        .lines()\n        .find_map(|line| {\n            line.trim()\n                .strip_prefix(\"uses: crate-ci/typos@v\")\n                .and_then(|v| Version::parse(v).ok())\n        })\n        .ok_or_else(|| anyhow::anyhow!(\"Could not find typos version in workflow\"))\n}\n\n/// If the given executable is installed with the given version, use that,\n/// otherwise install via cargo.\npub fn ensure_version_or_cargo_install(\n    build_dir: &Path,\n    required_version: Version,\n) -> io::Result<PathBuf> {\n    // Check if the user has a sufficient version already installed\n    let bin_path = PathBuf::from(BIN_NAME).with_extension(env::consts::EXE_EXTENSION);\n    if let Some(user_version) = get_typos_version(&bin_path) {\n        if user_version >= required_version {\n            return Ok(bin_path);\n        }\n    }\n\n    let tool_root_dir = build_dir.join(\"misc-tools\");\n    let tool_bin_dir = tool_root_dir.join(\"bin\");","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/crates/xtask-spellcheck/src/main.rs#L112-L148","documentation":"xtask-spellcheck parses the GitHub Actions workflow file to find the pinned `crate-ci/typos` version (the `uses: crate-ci/typos@vX.Y.Z` line) and parses it as a semver Version. If no such line is found, it bails with 'Could not find typos version in workflow'.","triggerScenarios":"Running `cargo spellcheck` when the workflow file no longer contains a `uses: crate-ci/typos@v...` line (renamed action, changed format, missing tag prefix), so Version::parse never succeeds.","commonSituations":"Editing the CI workflow to use a fork or a different action reference; bumping via dependabot that changes the line format; removing the typos step; the workflow path moved.","solutions":["Restore a `uses: crate-ci/typos@vX.Y.Z` line in the spellcheck GitHub Actions workflow file.","Update extract_typos_version_from_content's prefix matching if the workflow legitimately changed format.","Pin a concrete version tag (vX.Y.Z) rather than a branch/sha so the semver parse succeeds."],"exampleFix":"// before (workflow)\n- uses: crate-ci/typos@master\n// after\n- uses: crate-ci/typos@v1.20.0","handlingStrategy":"validation","validationCode":"// Verify the workflow references typos with a version tag\nlet wf = std::fs::read_to_string(workflow_path)?;\nif !wf.contains(\"uses: crate-ci/typos@v\") {\n    eprintln!(\"workflow missing crate-ci/typos@vX.Y.Z reference\");\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Pin typos to a vX.Y.Z tag in the workflow.","Keep the prefix 'uses: crate-ci/typos@v' stable when editing CI."],"tags":["cargo","xtask","spellcheck","ci","semver"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}