jdx/mise · error · TypeError

cannot encode #{value.class} as JSON

Error message

cannot encode #{value.class} as JSON

What it means

Git network operations (fetch, push, ls-remote) run through a sanitized plumbing wrapper that deliberately excludes -C/--work-tree, alternate index files, and stdin. network_output() validates the incoming PlumbingCall and rejects any call that sets work_tree, index_file, or stdin, since those options only make sense for local operations and hooks on mise's own repository must not be reachable from network calls.

Source

Thrown at src/system/packages/brew/tap_cask_metadata.rb:30

    when String
      '"' + value.each_codepoint.map { |codepoint|
        case codepoint
        when 0x08 then "\\b"
        when 0x09 then "\\t"
        when 0x0a then "\\n"
        when 0x0c then "\\f"
        when 0x0d then "\\r"
        when 0x22 then '\\"'
        when 0x5c then "\\\\"
        when 0...0x20 then format("\\u%04x", codepoint)
        else codepoint.chr("UTF-8")
        end
      }.join + '"'
    when Numeric then value.to_s
    when true then "true"
    when false then "false"
    when nil then "null"
    else raise TypeError, "cannot encode #{value.class} as JSON"
    end
  end
end

CASK_FILE = ENV.fetch("MISE_BREW_SOURCE_PATH")

module OS
  def self.mac? = ENV.fetch("MISE_BREW_OS") == "macos"
  def self.linux? = ENV.fetch("MISE_BREW_OS") == "linux"
end

class MacOSVersion
  include Comparable

  SYMBOLS = {
    tahoe: "26", sequoia: "15", sonoma: "14", ventura: "13",
    monterey: "12", big_sur: "11", catalina: "10.15", mojave: "10.14",
    high_sierra: "10.13", sierra: "10.12", el_capitan: "10.11"

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Build a PlumbingCall with work_tree: None, index_file: None, stdin: None for network operations
  2. Use the local plumbing executor instead if you genuinely need work tree/index/stdin
  3. Refactor call-site code so network and local calls construct separate PlumbingCall values

Example fix

// before
let call = PlumbingCall { args: &["fetch", "origin"], work_tree: Some(&repo), ..Default::default() };
git.network_output(call)?;

// after
let call = PlumbingCall { args: &["fetch", "origin"], ..Default::default() };
git.network_output(call)?;
Defensive patterns

Strategy: validation

Validate before calling

assert!(call.work_tree.is_none() && call.index_file.is_none() && call.stdin.is_none(),
    "network calls must not set work_tree/index_file/stdin");

Prevention

When it happens

Trigger: Calling Git::network_output with a PlumbingCall where work_tree, index_file, or stdin is Some(_) — e.g. reusing a call struct built for a local plumbing command and passing it to the network path.

Common situations: Developer code refactoring shared PlumbingCall construction accidentally populating work_tree/index_file for fetch/ls-remote; piping credentials or refs via stdin to a network call that doesn't support it.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/3d7b933f4baf6359. Report an issue: GitHub.