{"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":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/tap_cask_metadata.rb","lineNumber":343,"sourceCode":"  end\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":325,"sourceCodeEnd":345,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/tap_cask_metadata.rb#L325-L345","documentation":"Raised by mise's tap_cask_metadata.rb driver after evaluating the cask file: the cask block that was found declares a different token than the MISE_BREW_TOKEN env var the driver expects. mise extracts metadata for one specific cask and uses this guard to catch reading the wrong file or a cask whose token header does not match the requested tool.","triggerScenarios":"MISE_BREW_SOURCE_PATH points at a different cask file than MISE_BREW_TOKEN names; the cask's token was renamed upstream while mise still requests the old token; a header_token mismatch, e.g. cask file \"google-chrome.rb\" defining `cask \"google-chrome-dev\"`; copy/paste of one cask's body into another file.","commonSituations":"Upstream cask renames between header token and filename convention; stale tap checkout; mise's brew resolver and the tap checkout out of sync about the token.","solutions":["Point MISE_BREW_SOURCE_PATH at the cask file whose cask token equals MISE_BREW_TOKEN","Update the tap checkout so token and filename agree","Update mise or its pinned tap ref to pick up upstream cask renames","Fix the cask file so its header token matches its filename"],"exampleFix":"# before (cask file foo.rb)\ncask \"foo-cli\" do\n  version \"1.0\"\nend\n# after\ncask \"foo\" do\n  version \"1.0\"\nend","handlingStrategy":"validation","validationCode":"header = File.read(path)[/^\\s*cask\\s+[\"']([^\"']+)[\"']/, 1]\nraise \"token mismatch: #{header.inspect} != #{ENV.fetch('MISE_BREW_TOKEN')}\" unless header == ENV.fetch(\"MISE_BREW_TOKEN\")","typeGuard":"def token_matches?(path, expected) = File.read(path)[/^\\s*cask\\s+[\"']([^\"']+)[\"']/, 1] == expected","tryCatchPattern":"begin\n  metadata = parse_cask_metadata(cask_source)\nrescue RuntimeError => e\n  raise unless e.message.start_with?(\"expected cask \")\n  warn \"wrong cask file for token; re-resolving source path\"\nend","preventionTips":["Derive MISE_BREW_SOURCE_PATH from the token (tap path + \"#{token}.rb\") instead of hardcoding","Re-sync the tap after upstream cask renames","Verify the cask header token equals its filename before extraction"],"tags":["ruby","cask","token-mismatch","metadata"],"backgroundTag":"record-not-found","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"}