{"record":{"id":"78fa6c1f170db849","repo":"hyperledger/fabric","slug":"unknown-principal-anonymity-type-d","errorCode":null,"errorMessage":"Unknown principal anonymity type: %d","messagePattern":"Unknown principal anonymity type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"msp/mspimpl.go","lineNumber":603,"sourceCode":"// The function implements the additional behavior expected of an MSP starting from v1.3.\n// For pre-v1.3 functionality, the function calls the satisfiesPrincipalInternalPreV13.\nfunc (msp *bccspmsp) satisfiesPrincipalInternalV13(id Identity, principal *m.MSPPrincipal) error {\n\tswitch principal.PrincipalClassification {\n\tcase m.MSPPrincipal_COMBINED:\n\t\treturn errors.New(\"SatisfiesPrincipalInternal shall not be called with a CombinedPrincipal\")\n\tcase m.MSPPrincipal_ANONYMITY:\n\t\tanon := &m.MSPIdentityAnonymity{}\n\t\terr := proto.Unmarshal(principal.Principal, anon)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"could not unmarshal MSPIdentityAnonymity from principal\")\n\t\t}\n\t\tswitch anon.AnonymityType {\n\t\tcase m.MSPIdentityAnonymity_ANONYMOUS:\n\t\t\treturn errors.New(\"Principal is anonymous, but X.509 MSP does not support anonymous identities\")\n\t\tcase m.MSPIdentityAnonymity_NOMINAL:\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn errors.Errorf(\"Unknown principal anonymity type: %d\", anon.AnonymityType)\n\t\t}\n\n\tdefault:\n\t\t// Use the pre-v1.3 function to check other principal types\n\t\treturn msp.satisfiesPrincipalInternalPreV13(id, principal)\n\t}\n}\n\n// satisfiesPrincipalInternalV142 takes as arguments the identity and the principal.\n// The function returns an error if one occurred.\n// The function implements the additional behavior expected of an MSP starting from v2.0.\n// For v1.3 functionality, the function calls the satisfiesPrincipalInternalPreV13.\nfunc (msp *bccspmsp) satisfiesPrincipalInternalV142(id Identity, principal *m.MSPPrincipal) error {\n\t_, okay := id.(*identity)\n\tif !okay {\n\t\treturn errors.New(\"invalid identity type, expected *identity\")\n\t}\n","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/msp/mspimpl.go#L585-L621","documentation":"After unmarshaling the MSPIdentityAnonymity payload of an ANONYMITY-classified principal, satisfiesPrincipalInternalV13 accepts only ANONYMOUS and NOMINAL anonymity types. Any other enum value (or the unset zero value interpreted as unknown) falls into the default branch and produces this formatted error naming the offending numeric type.","triggerScenarios":"An MSPPrincipal with PrincipalClassification=ANONYMITY whose unmarshaled MSPIdentityAnonymity.AnonymityType is not ANONYMOUS or NOMINAL - typically 0 (unset) from an incompletely initialized message, or a value from a newer proto enum unknown to this build.","commonSituations":"Constructing the MSPIdentityAnonymity struct without setting AnonymityType before marshaling; deserializing policies produced by a newer fabric version with added enum values; corrupted policy bytes that decode to a garbage enum.","solutions":["Always set AnonymityType explicitly to ANONYMOUS or NOMINAL before marshaling the MSPIdentityAnonymity.","Check the numeric value printed in the error against the mspproto.MSPIdentityAnonymity_MSPIdentityAnonymityType enum to identify the mismatch.","Align fabric versions so the policy producer and the evaluating MSP agree on the anonymity enum values."],"exampleFix":"// before\nanon := &m.MSPIdentityAnonymity{} // AnonymityType left unset (0)\nb, _ := proto.Marshal(anon)\n// after\nanon := &m.MSPIdentityAnonymity{AnonymityType: m.MSPIdentityAnonymity_NOMINAL}\nb, _ := proto.Marshal(anon)","handlingStrategy":"validation","validationCode":"anon := &m.MSPIdentityAnonymity{}\nif err := proto.Unmarshal(principal.Principal, anon); err == nil {\n\tswitch anon.AnonymityType {\n\tcase m.MSPIdentityAnonymity_ANONYMOUS, m.MSPIdentityAnonymity_NOMINAL:\n\t\t// ok\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid anonymity type %d\", anon.AnonymityType)\n\t}\n}","typeGuard":"func hasKnownAnonymityType(p *m.MSPPrincipal) bool {\n\tanon := &m.MSPIdentityAnonymity{}\n\tif p == nil || p.PrincipalClassification != m.MSPPrincipal_ANONYMITY || proto.Unmarshal(p.Principal, anon) != nil {\n\t\treturn false\n\t}\n\treturn anon.AnonymityType == m.MSPIdentityAnonymity_ANONYMOUS || anon.AnonymityType == m.MSPIdentityAnonymity_NOMINAL\n}","tryCatchPattern":null,"preventionTips":["Never rely on the zero value of AnonymityType; set it explicitly.","Verify anonymity enum values after any protobuf/fabric version upgrade."],"tags":["msp","anonymity","enum","policy"],"backgroundTag":"invalid-enum-value","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"}