lutzroeder/netron · error · Error
Expected 'backend_name'.
Error message
Expected 'backend_name'.
What it means
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.
Source
Thrown at source/caffe2-proto.js:1132
static decode(reader, length) {
const message = new caffe2.BackendOptions();
const end = length === undefined ? reader.length : reader.position + length;
while (reader.position < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.backend_name = reader.string();
break;
case 2:
message.option.push(caffe2.MapFieldEntry.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
}
}
if (!Object.prototype.hasOwnProperty.call(message, 'backend_name')) {
throw new Error("Expected 'backend_name'.");
}
return message;
}
static decodeText(reader) {
const message = new caffe2.BackendOptions();
reader.start();
while (!reader.end()) {
const tag = reader.tag();
switch (tag) {
case "backend_name":
message.backend_name = reader.string();
break;
case "option":
message.option.push(caffe2.MapFieldEntry.decodeText(reader));
break;
default:
reader.field(tag, message);View on GitHub (pinned to d8a543f5f8)
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.
Example fix
// before const opts = caffe2.BackendOptions.decode(buf); // throws Expected 'backend_name' // after const info = caffe2.PartitionInfo.decode(fullBuf); const opts = info.backend_options; // decoded in context, offsets handled internally
Defensive patterns
Strategy: try-catch
Validate before calling
if (sub.length===0 || (sub[0]>>3)!==1) throw new RangeError('buffer does not start at BackendOptions.backend_name'); Type guard
const hasBackendName = (o) => o != null && typeof o.backend_name === 'string';
Try / catch
try { opts = caffe2.BackendOptions.decode(sub); } catch (e) { if (/Expected 'backend_name'/.test(e.message)) { decode parent instead; } else throw e; } Prevention
- Decode parent messages instead of manual slicing.
- Pin proto revisions between producer and consumer.
- Validate sub-buffer framing before decode.
When it happens
Trigger: 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.
Common situations: Parsing PARTITIONING backend options embedded in caffe2 plan/model files; extracting sub-messages with incorrect subarray bounds; decoding data from a different caffe2 build.
Related errors
AI-assisted analysis of lutzroeder/netron@d8a543f5f8 (2026-08-27).
Data as JSON: /api/errors/231e2ee84996e72b.
Report an issue: GitHub.