{"record":{"id":"71aab7ec97b0ea05","repo":"hyperledger/fabric","slug":"type-name-mismatch-s-s","errorCode":null,"errorMessage":"type name mismatch '%s' != '%s'","messagePattern":"type name mismatch '(.+?)' != '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/serializer.go","lineNumber":332,"sourceCode":"\t\t}\n\t}\n\tisSerialized = len(mismatches) == 0\n\treturn\n}\n\n// Deserialize accepts a struct (of a type previously serialized) and populates it with the values from the db.\n// Note: The struct names for the serialization and deserialization must match exactly.  Unencoded fields are not\n// populated, and the extraneous keys are ignored.  The metadata provided should have been returned by a DeserializeMetadata\n// call for the same namespace and name.\nfunc (s *Serializer) Deserialize(namespace, name string, metadata *lb.StateMetadata, structure any, state ReadableState) error {\n\tvalue, _, err := s.SerializableChecks(structure)\n\tif err != nil {\n\t\treturn errors.WithMessagef(err, \"could not deserialize namespace %s/%s to unserializable type %T\", namespace, name, structure)\n\t}\n\n\ttypeName := value.Type().Name()\n\tif typeName != metadata.Datatype {\n\t\treturn errors.Errorf(\"type name mismatch '%s' != '%s'\", typeName, metadata.Datatype)\n\t}\n\n\tfor i := 0; i < value.NumField(); i++ {\n\t\tfieldName := value.Type().Field(i).Name\n\t\tfieldValue := value.Field(i)\n\t\tswitch fieldValue.Kind() {\n\t\tcase reflect.String:\n\t\t\toneOf, err := s.DeserializeFieldAsString(namespace, name, fieldName, state)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfieldValue.SetString(oneOf)\n\t\tcase reflect.Int64:\n\t\t\toneOf, err := s.DeserializeFieldAsInt64(namespace, name, fieldName, state)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfieldValue.SetInt(oneOf)","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/serializer.go#L314-L350","documentation":"Serializer.Deserialize guard: the stored metadata's type name for a field-set does not match the Go struct name being deserialized into — the struct type changed between serialization and deserialization.","triggerScenarios":"Thrown at core/chaincode/lifecycle/serializer.go:332 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the same struct type (name) that was used when the state was serialized","Migrate the stored data or rename the struct back to match"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}