{"record":{"id":"ebdfbfc339d750d1","repo":"denoland/deno","slug":"invalid-commit-hash-passed-pass-a-semver-or","errorCode":null,"errorMessage":"Invalid commit hash passed ({})\n\nPass a semver, or a full 40 character git commit hash, or a release channel name.\n\nUsage:\n{}","messagePattern":"Invalid commit hash passed \\((.+?)\\)\n\nPass a semver, or a full 40 character git commit hash, or a release channel name\\.\n\nUsage:\n(.+?)","errorType":"validation","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tools/upgrade.rs","lineNumber":1260,"sourceCode":"          val.to_string(),\n        ));\n      } else {\n        maybe_passed_version = Some(val.to_string());\n      }\n    }\n\n    let Some(passed_version) = maybe_passed_version else {\n      return Ok(Self::Latest(channel));\n    };\n\n    let passed_version = passed_version\n      .strip_prefix('v')\n      .unwrap_or(&passed_version)\n      .to_string();\n\n    let (channel, passed_version) = if is_canary {\n      if !re_hash.is_match(&passed_version) {\n        bail!(\n          \"Invalid commit hash passed ({})\\n\\nPass a semver, or a full 40 character git commit hash, or a release channel name.\\n\\nUsage:\\n{}\",\n          colors::gray(passed_version),\n          UPGRADE_USAGE\n        );\n      }\n\n      (ReleaseChannel::Canary, passed_version)\n    } else {\n      let Ok(semver) = Version::parse_standard(&passed_version) else {\n        bail!(\n          \"Invalid version passed ({})\\n\\nPass a semver, or a full 40 character git commit hash, or a release channel name.\\n\\nUsage:\\n{}\",\n          colors::gray(passed_version),\n          UPGRADE_USAGE\n        );\n      };\n\n      if semver.pre.contains(&SmallStackString::from_static(\"alpha\")) {\n        (ReleaseChannel::Alpha, passed_version)","sourceCodeStart":1242,"sourceCodeEnd":1278,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/upgrade.rs#L1242-L1278","documentation":"When you pass an explicit version to `deno upgrade --canary`, the value must be a full 40-character git commit hash (matched against a hash regex). A leading `v` is stripped first; anything that is not 40 hex chars triggers this bail with the usage text. The canary channel is addressed by commit hash, not semver.","triggerScenarios":"`deno upgrade --canary abc123` (short hash), `--canary v1.2.3` (semver on the canary channel), or any value failing `re_hash` at cli/tools/upgrade.rs:1260.","commonSituations":"Copying a short 7-char hash from GitHub UI/commit logs; pasting a tag or semver while `--canary` is set; trailing whitespace/newlines pasted from terminals.","solutions":["Pass the full 40-character commit hash: copy it from the commit page (`gh api repos/denoland/deno/commits/<short>` resolves it).","If you meant a semver release, drop `--canary` and pass the version instead.","If you meant a named channel, use the channel name (stable/rc/beta) without a hash.","Check for stray characters (`v` is tolerated, anything else is not)."],"exampleFix":"# before\ndeno upgrade --canary 9f0a1b2  # short hash -> error\n\n# after\ndeno upgrade --canary 9f0a1b2c3d4e5f60718293a4b5c6d7e8f9011223  # full 40-char hash","handlingStrategy":"validation","validationCode":"# bash: accept only a full 40-hex commit hash for canary\n[[ \"$HASH\" =~ ^[0-9a-fA-F]{40}$ ]] || { echo \"pass a full 40-char commit hash\"; exit 1; }\ndeno upgrade --canary \"$HASH\"","typeGuard":"is_full_commit_hash() { [[ \"$1\" =~ ^[0-9a-fA-F]{40}$ ]]; }","tryCatchPattern":"deno upgrade --canary \"$HASH\" 2>err.log || { grep -q 'Invalid commit hash' err.log && gh api repos/denoland/deno/commits/\"${HASH:0:10}\" -q .sha; }","preventionTips":["Always expand short hashes to 40 chars (gh api resolves them).","Use `--canary` only with commit hashes; use plain versions without it.","Trim pasted values (a leading v is allowed, nothing else)."],"tags":["upgrade","canary","commit-hash","version","validation"],"backgroundTag":"invalid-version-string","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}