{"record":{"id":"dda37ddf5a1500db","repo":"jdx/mise","slug":"expected-cask-expected-got-metadata-token","errorCode":null,"errorMessage":"expected cask #{expected}, got #{metadata.token}","messagePattern":"expected cask #(.+?), got #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/tap_cask_metadata.rb","lineNumber":294,"sourceCode":"  private\n\n  def add_artifact(kind, source, target)\n    value = [source.to_s]\n    value << { \"target\" => target.to_s } unless target.nil?\n    @artifacts << { kind => value }\n  end\nend\n\ndef cask(token, &block)\n  $mise_cask_metadata = CaskMetadata.new(token)\n  $mise_cask_metadata.instance_eval(&block)\nend\n\neval(STDIN.read.force_encoding(\"UTF-8\"), TOPLEVEL_BINDING, CASK_FILE, 1)\nmetadata = $mise_cask_metadata\nraise \"no cask block found\" if metadata.nil?\nexpected = ENV.fetch(\"MISE_BREW_TOKEN\")\nraise \"expected cask #{expected}, got #{metadata.token}\" if metadata.token != expected\nputs JSON.generate(metadata.to_h)\n","sourceCodeStart":276,"sourceCodeEnd":296,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/tap_cask_metadata.rb#L276-L296","documentation":"mise's cask metadata extractor evals a Homebrew cask DSL file and compares the token passed to the top-level `cask` block against the expected token supplied via the MISE_BREW_TOKEN environment variable. When the cask file actually defines a different cask token than the one mise requested, this sanity-check raise fires with both tokens in the message. It guards against evaluating the wrong cask file (e.g. a mis-mapped source path or a renamed cask).","triggerScenarios":"Running src/system/packages/brew/tap_cask_metadata.rb with MISE_BREW_SOURCE_PATH pointing at a cask file whose `cask \"some-token\"` block does not match MISE_BREW_TOKEN — e.g. a casing/underscore mismatch, an alias cask file, or a cask renamed upstream.","commonSituations":"A third-party tap renamed a cask but the mise registry mapping still references the old token; the wrong file was fetched for the requested token (tap index stale or URL construction bug); casks with hyphens/underscores where token normalization differs; internal token like `cask \"foo@x\"` vs requested `foo`.","solutions":["Compare the two tokens in the message and make MISE_BREW_TOKEN match the token declared in the cask file's `cask \"...\"` block","Verify MISE_BREW_SOURCE_PATH points at the file for the requested cask (re-check the tap's Cask/ path spelling and case)","If the cask was renamed upstream, update the mise brew registry mapping/tool reference to the new token","Refresh the tap (git pull / re-fetch) so the file content matches the token you requested"],"exampleFix":"// before: requesting the wrong token\n//   MISE_BREW_TOKEN=\"google-chrome\"\n//   cask \"googlechrome\" do ... end  # actual token in file\n// after\n//   MISE_BREW_TOKEN=\"googlechrome\"\n//   cask \"googlechrome\" do ... end","handlingStrategy":"validation","validationCode":"# Run before invoking the extractor\ntoken = File.read(cask_path)[/\\bcask\\s+[\"']([^\"']+)[\"']/, 1]\nraise \"cask file token #{token.inspect} != expected #{expected.inspect}\" if token != expected","typeGuard":"def cask_token_matches?(file, expected)\n  File.read(file)[/^\\s*cask\\s+[\"']([^\"']+)[\"']/, 1] == expected\nend","tryCatchPattern":"begin\n  extract_cask_metadata(cask_path, token: expected)\nrescue RuntimeError => e\n  raise unless e.message.start_with?(\"expected cask \")\n  warn \"Requested token differs from cask file token: #{e.message}; re-check tap mapping\"\nend","preventionTips":["Grep the cask file for its `cask \"...\"` token and compare to MISE_BREW_TOKEN before extraction","Keep tap checkouts fresh so cask files are not renamed/stale relative to registry mappings","Assert MISE_BREW_SOURCE_PATH resolves under the tap's Cask/<token>.rb convention","Handle renamed casks by updating the mise brew registry entry, not the env var alone"],"tags":["homebrew","cask","token-mismatch","env-var"],"backgroundTag":"invalid-argument-value","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"}