{"record":{"id":"b30c30387a9889cf","repo":"lutzroeder/netron","slug":"expected-scale","errorCode":null,"errorMessage":"Expected 'scale'.","messagePattern":"Expected 'scale'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/caffe2-proto.js","lineNumber":271,"sourceCode":"                case 10:\n                    message.biases = reader.doubles(message.biases, tag);\n                    break;\n                case 11:\n                    message.axis = reader.int32();\n                    break;\n                case 12:\n                    message.is_multiparam = reader.bool();\n                    break;\n                default:\n                    reader.skipType(tag & 7);\n                    break;\n            }\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'precision')) {\n            throw new Error(\"Expected 'precision'.\");\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'scale')) {\n            throw new Error(\"Expected 'scale'.\");\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'bias')) {\n            throw new Error(\"Expected 'bias'.\");\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'is_signed')) {\n            throw new Error(\"Expected 'is_signed'.\");\n        }\n        return message;\n    }\n\n    static decodeText(reader) {\n        const message = new caffe2.QTensorProto();\n        reader.start();\n        while (!reader.end()) {\n            const tag = reader.tag();\n            switch (tag) {\n                case \"dims\":\n                    reader.array(message.dims, () => reader.int64());","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/lutzroeder/netron/blob/d8a543f5f847ef596aa58858d6adcf5d75545f7f/source/caffe2-proto.js#L253-L289","documentation":"Generated protobuf requirement check: a binary-decoded caffe2.QTensorProto lacks the required 'scale' field. decode() checks precision, scale, bias and is_signed in order and throws as soon as one is absent, here at the second check.","triggerScenarios":"Decoding QTensorProto bytes where precision was present but scale (field for quantization scale) was not — truncated wire data or mismatched schema/producer version.","commonSituations":"Quantized caffe2 model files from incompatible toolchains; partial file transfers; misparsed stream alignment.","solutions":["Verify the quantized model was produced by a compatible caffe2 version and re-export","Check the file size/checksum against the source","Decode with protoc --decode_raw to confirm the scale field exists in the bytes","Ensure the reader is positioned on a genuine QTensorProto payload"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const REQUIRED = ['precision','scale','bias','is_signed'];\nconst missing = REQUIRED.filter((k) => !(k in qt));\nif (missing.length) throw new Error(`QTensorProto missing: ${missing.join(', ')}`);","typeGuard":"function isQTensor(m) {\n  return m != null && ['precision','scale','bias','is_signed']\n    .every((k) => Object.prototype.hasOwnProperty.call(m, k));\n}","tryCatchPattern":"try {\n  caffe2.QTensorProto.decode(reader);\n} catch (e) {\n  if (/^Expected '(precision|scale|bias|is_signed)'\\.$/.test(e.message)) {\n    // corrupt/incomplete quantized data — abort load with clear message\n  } else throw e;\n}","preventionTips":["Checksum quantized model files before decoding","Never mix weight files across model versions","Log which required field failed to speed diagnosis"],"tags":["caffe2","protobuf","qtensor","required-field"],"backgroundTag":"protobuf-missing-required-field","analyzedSha":"d8a543f5f847ef596aa58858d6adcf5d75545f7f","analyzedAt":"2026-08-27T19:21:42.082Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}