{"record":{"id":"d62031043e42fb35","repo":"ruby/ruby","slug":"no-implicit-conversion-of-json-class-into-stri","errorCode":null,"errorMessage":" no implicit conversion of #{json.class} into String","messagePattern":" no implicit conversion of #(.+?) into String","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/json/lib/json/common.rb","lineNumber":186,"sourceCode":"        \"#{super_message}\\nInvalid object: #{@invalid_object.inspect}\"\n      end\n    end\n  end\n\n  # Fragment of JSON document that is to be included as is:\n  #   fragment = JSON::Fragment.new(\"[1, 2, 3]\")\n  #   JSON.generate({ count: 3, items: fragments })\n  #\n  # This allows to easily assemble multiple JSON fragments that have\n  # been persisted somewhere without having to parse them nor resorting\n  # to string interpolation.\n  #\n  # Note: no validation is performed on the provided string. It is the\n  # responsibility of the caller to ensure the string contains valid JSON.\n  Fragment = Struct.new(:json) do\n    def initialize(json)\n      unless string = String.try_convert(json)\n        raise TypeError, \" no implicit conversion of #{json.class} into String\"\n      end\n\n      super(string)\n    end\n\n    def to_json(state = nil, *)\n      json\n    end\n  end\n\n  module_function\n\n  # :call-seq:\n  #   JSON.parse(source, opts) -> object\n  #\n  # Returns the Ruby objects created by parsing the given +source+.\n  #\n  # Argument +source+ contains the \\String to be parsed.","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/ext/json/lib/json/common.rb#L168-L204","documentation":"Raised by Gem::Package::Old#spec (outer rescue ArgumentError branch) with the same 'Failed to parse gem specification out of gem file' message, but for ArgumentError from Gem::Specification.from_yaml instead of Psych::SyntaxError. Psych/SafeYAML raises ArgumentError for structural problems that are syntactically valid YAML but invalid as a specification — unknown aliases/tags, unexpected object shapes, or non-string keys under safe loading.","triggerScenarios":"Old-format gem whose YAML parses but does not load: e.g. YAML referencing an undefined alias, a gemspec serialized with Ruby-object tags (!ruby/object) that safe loading rejects, or a spec whose top-level structure is a sequence instead of a mapping. Distinct from error 513: the YAML text itself is well-formed.","commonSituations":"Gems packaged by very old Ruby/RubyGems whose YAML serializer emitted constructs modern Psych refuses; hand-merged spec YAML from different gems; security hardening (safe_yaml) rejecting object deserialization that old Ruby allowed.","solutions":["Run a modern re-release of the gem instead of the pre-1.0 artifact","If inspection is required, extract the YAML block and load it with Psych.safe_load per-field to find the rejected construct","Re-download in case of corruption","Report the gem to its mirror if the artifact is provably damaged"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# probe whether the spec YAML survives safe loading before install\nrequire 'psych'\nPsych.safe_load(extract_spec_section(File.read(path)), permitted_classes: [Date, Time, Gem::Dependency], aliases: false)","typeGuard":null,"tryCatchPattern":"begin\n  Gem::Package::Old.new(io).spec\nrescue Gem::Exception => e\n  warn \"old gem uses YAML unsafe to load: #{e.message}\"\nend","preventionTips":["Expect pre-1.0 YAML to be incompatible with modern safe loading; use modern releases","When migrating archival gems, convert specs through a reviewed manual step rather than automated install"],"tags":["rubygems","old-format","yaml","safe-load","spec"],"backgroundTag":"yaml-parse-error","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}