{"record":{"id":"e312766942bfc42b","repo":"jdx/mise","slug":"formula-has-no-stable-sha256","errorCode":null,"errorMessage":"formula has no stable sha256","messagePattern":"formula has no stable sha256","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/tap_formula_metadata.rb","lineNumber":238,"sourceCode":"# Match the formulae.brew.sh JSON: symbol reasons serialize as \":name\",\n# string reasons as-is.\ndef keg_only_reason_metadata(klass)\n  reason = klass.keg_only_reason_value\n  return nil if reason.nil?\n  { \"reason\" => reason.is_a?(Symbol) ? reason.inspect : reason.to_s }\nend\n\ndef inferred_version(url)\n  basename = File.basename(url.to_s).sub(/\\.(tar\\.(gz|xz|bz2|zst)|tgz|txz|zip|gz)\\z/i, \"\")\n  match = basename.match(/(?:^|[-_v])([0-9]+(?:\\.[0-9A-Za-z]+)+(?:[-_.][0-9A-Za-z]+)*)/)\n  match && match[1]\nend\n\neval(STDIN.read.force_encoding(\"UTF-8\"), TOPLEVEL_BINDING, FORMULA_FILE, 1)\nklass = Formula.instance_variable_get(:@subclass)\nraise \"no Formula subclass found\" unless klass\nraise \"formula has no stable URL\" if klass.source_url.to_s.empty?\nraise \"formula has no stable sha256\" if klass.source_sha256.to_s.empty?\nversion = (klass.explicit_version || inferred_version(klass.source_url)).to_s\nraise \"could not infer formula version; add an explicit version declaration\" if version.to_s.empty?\n\nmetadata = {\n  \"name\" => FORMULA_NAME,\n  \"tap\" => ENV.fetch(\"MISE_BREW_TAP\"),\n  \"versions\" => { \"stable\" => version },\n  \"revision\" => klass.revision_value || 0,\n  \"keg_only\" => klass.keg_only_value || false,\n  \"keg_only_reason\" => keg_only_reason_metadata(klass),\n  \"dependencies\" => klass.runtime_dependencies || [],\n  \"build_dependencies\" => klass.build_dependencies || [],\n  \"bottle\" => {},\n  \"urls\" => { \"stable\" => { \"url\" => klass.source_url, \"checksum\" => klass.source_sha256 } },\n  \"ruby_source_path\" => ENV.fetch(\"MISE_BREW_SOURCE_PATH\"),\n  \"ruby_source_checksum\" => { \"sha256\" => ENV.fetch(\"MISE_BREW_SOURCE_CHECKSUM\") },\n  \"tap_git_head\" => ENV.fetch(\"MISE_BREW_TAP_COMMIT\")\n}","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/tap_formula_metadata.rb#L220-L256","documentation":"Raised by mise's tap_formula_metadata.rb when the formula class exists and has a stable source_url but no stable source sha256. The sha256 is required so mise can verify the downloaded source archive; building without it would skip integrity checking, so the shim refuses to emit metadata instead.","triggerScenarios":"Formula omits the sha256 stanza; sha256 is set only for a spec the shim is not reading (e.g. inside on_macos/on_linux blocks or a non-stable spec); the formula relies on Homebrew-only mechanisms like bottle-only distribution; sha256 :no_check usage the shim does not accept.","commonSituations":"Hand-written third-party formulae missing checksums; formulae updated upstream to conditional sha256 blocks; conversion of Homebrew JSON metadata that dropped the checksum.","solutions":["Add a correct `sha256` stanza (hash of the source archive at url) to the formula","Extend the shim to read sha256 from the block the formula uses","Pin the formula to a revision that declares a stable sha256","Use a formula variant that provides checksums instead of sha256 :no_check"],"exampleFix":"# before (formula)\nclass Foo < Formula\n  version \"1.0\"\n  url \"https://example.com/foo-1.0.tar.gz\"\nend\n# after\nclass Foo < Formula\n  version \"1.0\"\n  url \"https://example.com/foo-1.0.tar.gz\"\n  sha256 \"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\"\nend","handlingStrategy":"validation","validationCode":"raise \"formula has no sha256\" unless formula_source.match?(/^\\s*sha256\\s+[\"'][0-9a-f]{64}[\"']/)","typeGuard":"def has_stable_sha256?(klass) = !klass.source_sha256.to_s.empty?","tryCatchPattern":"begin\n  metadata = parse_formula_metadata(formula_source)\nrescue RuntimeError => e\n  raise unless e.message == \"formula has no stable sha256\"\n  warn \"formula lacks a sha256; cannot verify source\"\nend","preventionTips":["Always compute and declare sha256 for the source archive in hand-written formulae","Avoid sha256 :no_check when integrity matters","Resolve sha256 declared in conditional blocks for the target platform before extraction"],"tags":["ruby","formula","checksum","missing-field"],"backgroundTag":"empty-required-field","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}