{"record":{"id":"231e2ee84996e72b","repo":"lutzroeder/netron","slug":"expected-backend-name","errorCode":null,"errorMessage":"Expected 'backend_name'.","messagePattern":"Expected 'backend_name'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/caffe2-proto.js","lineNumber":1132,"sourceCode":"    static decode(reader, length) {\n        const message = new caffe2.BackendOptions();\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.backend_name = reader.string();\n                    break;\n                case 2:\n                    message.option.push(caffe2.MapFieldEntry.decode(reader, reader.uint32()));\n                    break;\n                default:\n                    reader.skipType(tag & 7);\n                    break;\n            }\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'backend_name')) {\n            throw new Error(\"Expected 'backend_name'.\");\n        }\n        return message;\n    }\n\n    static decodeText(reader) {\n        const message = new caffe2.BackendOptions();\n        reader.start();\n        while (!reader.end()) {\n            const tag = reader.tag();\n            switch (tag) {\n                case \"backend_name\":\n                    message.backend_name = reader.string();\n                    break;\n                case \"option\":\n                    message.option.push(caffe2.MapFieldEntry.decodeText(reader));\n                    break;\n                default:\n                    reader.field(tag, message);","sourceCodeStart":1114,"sourceCodeEnd":1150,"githubUrl":"https://github.com/lutzroeder/netron/blob/d8a543f5f847ef596aa58858d6adcf5d75545f7f/source/caffe2-proto.js#L1114-L1150","documentation":"Generated binary decoder for caffe2.BackendOptions rejects data missing the required 'backend_name' field. The verifier runs after the field loop; if the wire bytes never carried field 1 (backend_name), it throws this error.","triggerScenarios":"BackendOptions.decode() on bytes missing the backend_name field — wrong buffer offset when slicing from a parent PartitionInfo message, empty buffers, or schema drift between proto versions.","commonSituations":"Parsing PARTITIONING backend options embedded in caffe2 plan/model files; extracting sub-messages with incorrect subarray bounds; decoding data from a different caffe2 build.","solutions":["Slice the sub-buffer using the correct field length from the parent message rather than guessing offsets.","Regenerate caffe2-proto.js from the .proto matching the data producer.","Prefer decoding the parent PartitionInfo and accessing .backend_options instead of manual slicing.","Sanity-check buffer length > 0 before decoding."],"exampleFix":"// before\nconst opts = caffe2.BackendOptions.decode(buf); // throws Expected 'backend_name'\n\n// after\nconst info = caffe2.PartitionInfo.decode(fullBuf);\nconst opts = info.backend_options; // decoded in context, offsets handled internally","handlingStrategy":"try-catch","validationCode":"if (sub.length===0 || (sub[0]>>3)!==1) throw new RangeError('buffer does not start at BackendOptions.backend_name');","typeGuard":"const hasBackendName = (o) => o != null && typeof o.backend_name === 'string';","tryCatchPattern":"try { opts = caffe2.BackendOptions.decode(sub); } catch (e) { if (/Expected 'backend_name'/.test(e.message)) { decode parent instead; } else throw e; }","preventionTips":["Decode parent messages instead of manual slicing.","Pin proto revisions between producer and consumer.","Validate sub-buffer framing before decode."],"tags":["protobuf","required-field","caffe2","backend-config"],"backgroundTag":"protobuf-missing-required-field","analyzedSha":"d8a543f5f847ef596aa58858d6adcf5d75545f7f","analyzedAt":"2026-08-27T19:21:42.082Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}