{"record":{"id":"531ace66f59ff227","repo":"lutzroeder/netron","slug":"unexpected-end-of-file","errorCode":null,"errorMessage":"Unexpected end of file.","messagePattern":"Unexpected end of file\\.","errorType":"exception","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"source/protobuf.js","lineNumber":471,"sourceCode":"            }\n        }\n        return true;\n    }\n\n    entry(obj, key, value) {\n        this.skipVarint();\n        this.skip(1);\n        let k = key();\n        if (!Number.isInteger(k) && typeof k !== 'string') {\n            k = Number(k);\n        }\n        this.skip(1);\n        const v = value();\n        obj[k] = v;\n    }\n\n    _unexpected() {\n        throw new RangeError('Unexpected end of file.');\n    }\n};\n\nprotobuf.BufferReader = class extends protobuf.BinaryReader {\n\n    constructor(buffer, offset = 0) {\n        super();\n        this._buffer = buffer;\n        this._length = buffer.length;\n        this._position = offset;\n        this._view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n    }\n\n    skipVarint() {\n        do {\n            if (this._position >= this._length) {\n                this._unexpected();\n            }","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/lutzroeder/netron/blob/d8a543f5f847ef596aa58858d6adcf5d75545f7f/source/protobuf.js#L453-L489","documentation":"A RangeError raised by the generic text/protobuf reader's _unexpected() handler, which is wired as the out-of-bounds callback for array/string access helpers (floats, doubles, skip, skipVarint). It fires when one of those helpers would read past the end of the input while decoding a message.","triggerScenarios":"Decoding a message whose declared repeated-field count or varint length implies more bytes than remain; _unexpected is invoked by the helper library when the underlying index is out of bounds.","commonSituations":"Truncated serialized protos, wrong-length buffers sliced with bad offsets, or decoding a payload with the wrong message type so lengths are misinterpreted.","solutions":["Verify the input buffer is complete and you are decoding starting at the correct offset.","Confirm the message type matches the schema the data was encoded with.","Catch RangeError around decode and surface a 'corrupted input' error to callers."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (buffer.length === 0) {\n    throw new Error('Refusing to decode empty buffer');\n}","typeGuard":null,"tryCatchPattern":"try { const msg = Proto.decode(buf); } catch (e) { if (e instanceof RangeError && e.message === 'Unexpected end of file.') throw new Error('Corrupted or truncated protobuf input'); throw e; }","preventionTips":["Validate buffer completeness (length/checksum) before decode.","Ensure slice offsets are within bounds when splitting payloads.","Decode with the exact schema the producer used."],"tags":["protobuf","range-error","truncated-input","decode"],"backgroundTag":"unexpected-end-of-file","analyzedSha":"d8a543f5f847ef596aa58858d6adcf5d75545f7f","analyzedAt":"2026-08-27T19:21:42.082Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}