{"record":{"id":"0a3724183e25ced8","repo":"jdx/mise","slug":"context-missing-sha256","errorCode":null,"errorMessage":"#{context}: missing sha256","messagePattern":"#(.+?): missing sha256","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":72,"sourceCode":"\ndef odie(message)\n  $stderr.puts \"Error: #{message}\"\n  exit 1\nend\n\nclass ShimUnsupportedError < StandardError; end\n\ndef shim_unsupported!(feature)\n  raise ShimUnsupportedError,\n        \"formula uses `#{feature}`, which mise's source-build shim does not support\"\nend\n\nmodule MiseDownload\n  module_function\n\n  # download with redirects into the cache, verify, return the path\n  def fetch(url, sha256, context)\n    raise \"#{context}: missing sha256\" if sha256.to_s.strip.empty?\n    sha256 = sha256.to_s.strip.downcase\n    raise \"#{context}: malformed sha256\" unless sha256.match?(/\\A[0-9a-f]{64}\\z/)\n\n    MISE_BREW_CACHE.mkpath\n    dest = MISE_BREW_CACHE + \"#{sha256}--#{File.basename(URI(url).path)}\"\n    unless dest.file? && Digest::SHA256.file(dest).hexdigest == sha256\n      ohai \"Downloading #{url}\"\n      tmp = Pathname.new(\"#{dest}.incomplete\")\n      URI.open(url, \"rb\", redirect: true) do |remote|\n        tmp.open(\"wb\") { |f| IO.copy_stream(remote, f) }\n      end\n      actual = Digest::SHA256.file(tmp).hexdigest\n      if actual != sha256\n        tmp.unlink\n        raise \"#{context}: sha256 mismatch (expected #{sha256}, got #{actual})\"\n      end\n      tmp.rename(dest)\n    end","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/shim.rb#L54-L90","documentation":"The Ruby brew shim's MiseDownload.fetch refuses to download when the caller passes an empty or blank sha256. Every fetched artifact must have a checksum so the cache is content-addressed and verified; a missing digest means mise cannot guarantee artifact integrity, so fetch raises immediately.","triggerScenarios":"A brew shim package recipe calls cc/cxx-backed fetch with sha256 nil, '', or whitespace only — e.g. a recipe template that failed to substitute the checksum.","commonSituations":"Hand-written or generated package recipes missing the sha256 field; templating producing empty checksums; upstream metadata lacking the digest.","solutions":["Provide the correct 64-hex-character sha256 for the artifact in the recipe/invocation.","Compute it locally: curl -L <url> | sha256sum, then put the digest into the package config.","Regenerate the recipe with a template that includes the checksum field.","If the artifact upstream doesn't publish a checksum, pin a version that does or vendor the file."],"exampleFix":"// before\nMiseDownload.fetch(url, nil, \"clang\")\n// after\nMiseDownload.fetch(url, \"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\", \"clang\")","handlingStrategy":"validation","validationCode":"# ruby guard before calling fetch\nraise \"sha256 required\" if sha256.nil? || sha256.to_s.strip.empty?\nMiseDownload.fetch(url, sha256, context)","typeGuard":null,"tryCatchPattern":"begin\n  MiseDownload.fetch(url, sha256, context)\nrescue RuntimeError => e\n  raise unless e.message.include?(\"missing sha256\")\n  # fall back or surface a config error\nend","preventionTips":["Always include a sha256 in package recipes; treat it as mandatory.","Generate recipes from templates that require the checksum field.","Compute checksums from official release checksum files."],"tags":["ruby","download","checksum","brew"],"backgroundTag":"missing-required-argument","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}