{"record":{"id":"cfa23be41b8bb796","repo":"lutzroeder/netron","slug":"expected-quant-algo-name","errorCode":null,"errorMessage":"Expected 'quant_algo_name'.","messagePattern":"Expected 'quant_algo_name'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"source/mindir-proto.js","lineNumber":1111,"sourceCode":"    static decode(reader, length) {\n        const message = new mind_ir.TensorProto.QuantParamProto();\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.quant_algo_name = reader.string();\n                    break;\n                case 2:\n                    message.attribute.push(mind_ir.AttributeProto.decode(reader, reader.uint32()));\n                    break;\n                default:\n                    reader.skipType(tag & 7);\n                    break;\n            }\n        }\n        if (!Object.prototype.hasOwnProperty.call(message, 'quant_algo_name')) {\n            throw new Error(\"Expected 'quant_algo_name'.\");\n        }\n        return message;\n    }\n\n    static decodeText(reader) {\n        const message = new mind_ir.TensorProto.QuantParamProto();\n        reader.start();\n        while (!reader.end()) {\n            const tag = reader.tag();\n            switch (tag) {\n                case \"quant_algo_name\":\n                    message.quant_algo_name = reader.string();\n                    break;\n                case \"attribute\":\n                    message.attribute.push(mind_ir.AttributeProto.decodeText(reader));\n                    break;\n                default:\n                    reader.field(tag, message);","sourceCodeStart":1093,"sourceCodeEnd":1129,"githubUrl":"https://github.com/lutzroeder/netron/blob/d8a543f5f847ef596aa58858d6adcf5d75545f7f/source/mindir-proto.js#L1093-L1129","documentation":"Thrown by the generated protobuf decoder for mind_ir.TensorProto.QuantParamProto when a decoded message is missing the required field 'quant_algo_name'. In .proto declarations, fields without a label are required in proto2 semantics, so the decoder verifies presence after consuming all input bytes. It indicates the serialized tensor's quant_param message never set quant_algo_name.","triggerScenarios":"Calling mindir.TensorProto.QuantParamProto.decode (or decoding a parent TensorProto containing a quant_param) on a buffer where the quant_param submessage has no field with tag corresponding to quant_algo_name (field 1).","commonSituations":"Loading a MindIR model produced by an older/newer MindSpore version where quant_param became optional, hand-crafted or truncated serialized protos, or exporting a quantized model whose quantization parameters were never populated.","solutions":["Verify the model file was produced by a MindSpore version compatible with the mindir-proto schema bundled in this library.","Re-export the MindIR model ensuring quantization params include quant_algo_name.","If you control the schema build, regenerate the proto with quant_algo_name as optional, or patch the generated decoder to remove the required-field check.","Inspect the raw bytes of the tensor's quant_param submessage to confirm the field is absent vs. corrupted."],"exampleFix":"// before\nconst quant = mindir.TensorProto.QuantParamProto.decode(reader);\n\n// after — tolerate models missing the required field\nconst proto = require('./mindir-proto.js');\nconst origDecode = proto.mind_ir.TensorProto.QuantParamProto.decode;\nproto.mind_ir.TensorProto.QuantParamProto.decode = function (reader, length) {\n    const save = reader.pos;\n    try {\n        return origDecode.call(this, reader, length);\n    } catch (e) {\n        if (e.message === \"Expected 'quant_algo_name'.\") {\n            reader.pos = save;\n            return origDecode.call(this, reader, length); // decode again via patched schema without required check\n        }\n        throw e;\n    }\n};","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    const quant = mindir.TensorProto.QuantParamProto.decode(reader);\n} catch (e) {\n    if (e.message === \"Expected 'quant_algo_name'.\") {\n        // treat as missing quantization info; substitute defaults\n        return { quant_algo_name: 'DEFAULT' };\n    }\n    throw e;\n}","preventionTips":["Pin the MindSpore version used for export and for parsing to keep proto schemas aligned.","When generating protos, mark optional fields optional to avoid required-field throws.","Smoke-decode one quantized tensor after export to catch schema issues early."],"tags":["protobuf","mindir","mindspore","required-field","schema-mismatch"],"backgroundTag":"protobuf-missing-required-field","analyzedSha":"d8a543f5f847ef596aa58858d6adcf5d75545f7f","analyzedAt":"2026-08-27T19:21:42.082Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}