{"record":{"id":"45f720ba8523f170","repo":"ruby/rubygems","slug":"expected-n-bytes-got-eof","errorCode":null,"errorMessage":"expected #{n} bytes, got EOF","messagePattern":"expected #(.+?) bytes, got EOF","errorType":"exception","errorClass":"Gem::SafeMarshal::Reader::EOFError","httpStatus":null,"severity":"error","filePath":"lib/rubygems/safe_marshal/reader.rb","lineNumber":58,"sourceCode":"        root = read_element\n        raise UnconsumedBytesError, \"expected EOF, got #{@io.read(10).inspect}... after top-level element #{root.class}\" unless @io.eof?\n        root\n      end\n\n      private\n\n      MARSHAL_VERSION = [Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION].map(&:chr).join.freeze\n      private_constant :MARSHAL_VERSION\n\n      def read_header\n        v = @io.read(2)\n        raise UnsupportedVersionError, \"Unsupported marshal version #{v.bytes.map(&:ord).join(\".\")}, expected #{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}\" unless v == MARSHAL_VERSION\n      end\n\n      def read_bytes(n)\n        raise NegativeLengthError if n < 0\n        str = @io.read(n)\n        raise EOFError, \"expected #{n} bytes, got EOF\" if str.nil?\n        raise DataTooShortError, \"expected #{n} bytes, got #{str.inspect}\" unless str.bytesize == n\n        str\n      end\n\n      def read_byte\n        @io.getbyte || raise(EOFError, \"Unexpected EOF\")\n      end\n\n      def read_integer\n        b = read_byte\n\n        case b\n        when 0x00\n          0\n        when 0x01\n          read_byte\n        when 0x02\n          read_byte | (read_byte << 8)","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/safe_marshal/reader.rb#L40-L76","documentation":"Error \"expected #{n} bytes, got EOF\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/safe_marshal/reader.rb:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The marshal data is truncated; re-download the gem or metadata file"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}