{"record":{"id":"d094fd567f3f15d1","repo":"lutzroeder/netron","slug":"expected-begin","errorCode":null,"errorMessage":"Expected 'begin'.","messagePattern":"Expected 'begin'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/caffe2-proto.js","lineNumber":173,"sourceCode":"    static decode(reader, length) {\n        const message = new caffe2.TensorProto.Segment();\n        const end = length === undefined ? reader.length : reader.position + length;\n        while (reader.position < end) {\n            const tag = reader.uint32();\n            switch (tag >>> 3) {\n                case 1:\n                    message.begin = reader.int64();\n                    break;\n                case 2:\n                    message.end = reader.int64();\n                    break;\n                default:\n                    reader.skipType(tag & 7);\n                    break;\n            }\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'begin')) {\n            throw new Error(\"Expected 'begin'.\");\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'end')) {\n            throw new Error(\"Expected 'end'.\");\n        }\n        return message;\n    }\n\n    static decodeText(reader) {\n        const message = new caffe2.TensorProto.Segment();\n        reader.start();\n        while (!reader.end()) {\n            const tag = reader.tag();\n            switch (tag) {\n                case \"begin\":\n                    message.begin = reader.int64();\n                    break;\n                case \"end\":\n                    message.end = reader.int64();","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/lutzroeder/netron/blob/d8a543f5f847ef596aa58858d6adcf5d75545f7f/source/caffe2-proto.js#L155-L191","documentation":"Generated protobuf requirement check: after decoding a caffe2.TensorProto.Segment from binary, the required field 'begin' was never set. proto2-style required fields must be present; if the wire input never carried field 1, decode() throws before returning the message.","triggerScenarios":"Decoding a TensorProto.Segment payload (as part of parsing a caffe2 predictor/initials file) whose serialized bytes omit the required 'begin' field — either a truncated message or bytes that aren't actually a Segment.","commonSituations":"Corrupt or truncated .pb/.init files, version mismatches where an older producer omitted the field, or feeding arbitrary binary to the caffe2 loader so a wrong message type is decoded from those bytes.","solutions":["Validate the source of the .pb file and re-export it from Caffe2","Verify you are decoding the right message type at that position (misaligned stream decodes garbage)","Check the file was transferred fully (checksum/size)","Regenerate the model with a toolchain matching the library's caffe2.proto version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate decoded message before use\nclass Segment { constructor() { this.begin = 0; this.end = 0; } }\nconst ok = (m) => m instanceof Segment && 'begin' in m && 'end' in m;","typeGuard":"function isSegment(m) {\n  return m != null && typeof m === 'object' &&\n    Object.prototype.hasOwnProperty.call(m, 'begin') &&\n    Object.prototype.hasOwnProperty.call(m, 'end');\n}","tryCatchPattern":"try {\n  const seg = caffe2.TensorProto.Segment.decode(reader);\n} catch (e) {\n  if (e.message === \"Expected 'begin'.\") {\n    // mark source model invalid; skip tensor, don't retry\n  } else throw e;\n}","preventionTips":["Only decode bytes produced by a compatible caffe2 export","Checksum model files before loading","Pre-validate with protoc --decode_raw when source is uncertain"],"tags":["caffe2","protobuf","required-field","segment"],"backgroundTag":"protobuf-missing-required-field","analyzedSha":"d8a543f5f847ef596aa58858d6adcf5d75545f7f","analyzedAt":"2026-08-27T19:21:42.082Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}