hyperledger/fabric · error
type name mismatch '%s' != '%s'
Error message
type name mismatch '%s' != '%s'
What it means
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.
Source
Thrown at core/chaincode/lifecycle/serializer.go:332
}
}
isSerialized = len(mismatches) == 0
return
}
// Deserialize accepts a struct (of a type previously serialized) and populates it with the values from the db.
// Note: The struct names for the serialization and deserialization must match exactly. Unencoded fields are not
// populated, and the extraneous keys are ignored. The metadata provided should have been returned by a DeserializeMetadata
// call for the same namespace and name.
func (s *Serializer) Deserialize(namespace, name string, metadata *lb.StateMetadata, structure any, state ReadableState) error {
value, _, err := s.SerializableChecks(structure)
if err != nil {
return errors.WithMessagef(err, "could not deserialize namespace %s/%s to unserializable type %T", namespace, name, structure)
}
typeName := value.Type().Name()
if typeName != metadata.Datatype {
return errors.Errorf("type name mismatch '%s' != '%s'", typeName, metadata.Datatype)
}
for i := 0; i < value.NumField(); i++ {
fieldName := value.Type().Field(i).Name
fieldValue := value.Field(i)
switch fieldValue.Kind() {
case reflect.String:
oneOf, err := s.DeserializeFieldAsString(namespace, name, fieldName, state)
if err != nil {
return err
}
fieldValue.SetString(oneOf)
case reflect.Int64:
oneOf, err := s.DeserializeFieldAsInt64(namespace, name, fieldName, state)
if err != nil {
return err
}
fieldValue.SetInt(oneOf)View on GitHub (pinned to 2736b63f8f)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at core/chaincode/lifecycle/serializer.go:332 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/71aab7ec97b0ea05.
Report an issue: GitHub.