{"record":{"id":"570fd5f3613b3b62","repo":"hyperledger/fabric","slug":"msp-principal-role-s-not-recognized","errorCode":null,"errorMessage":"MSP Principal role [%s] not recognized","messagePattern":"MSP Principal role \\[(.+?)\\] not recognized","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/policy/principal.go","lineNumber":76,"sourceCode":"\t\t\treturn nil, errors.Wrap(err, \"marshalling failed\")\n\t\t}\n\n\t\treturn &protomsp.MSPPrincipal{\n\t\t\tPrincipalClassification: protomsp.MSPPrincipal_ROLE,\n\t\t\tPrincipal:               principalBytes,\n\t\t}, nil\n\tcase Members:\n\t\tprincipalBytes, err := proto.Marshal(&protomsp.MSPRole{Role: protomsp.MSPRole_MEMBER, MspIdentifier: mspid})\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"marshalling failed\")\n\t\t}\n\n\t\treturn &protomsp.MSPPrincipal{\n\t\t\tPrincipalClassification: protomsp.MSPPrincipal_ROLE,\n\t\t\tPrincipal:               principalBytes,\n\t\t}, nil\n\tdefault:\n\t\treturn nil, errors.Errorf(\"MSP Principal role [%s] not recognized\", role)\n\t}\n}\n","sourceCodeStart":58,"sourceCodeEnd":79,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/policy/principal.go#L58-L79","documentation":"localMSPPrincipalGetter.Get only recognizes the literal role strings 'Admins' and 'Members' (the exported constants). Any other role string hits the default branch and returns this error. It means the caller passed a role name that the local principal getter cannot map to an MSPPrincipal.","triggerScenarios":"Calling CheckPolicyNoChannelBySignedData (policy.go:209 principalGetter.Get(policyName)) with a policyName other than exactly \"Admins\" or \"Members\" — e.g. passing a channel policy name like \"Writers\", \"Readers\", a path like \"/Channel/Application/Admins\", or a misspelled/locally defined policy name into the channelless local-MSP check.","commonSituations":"Mixing up channel policy names with the channelless local policy names ('Admins'/'Members'); older Fabric code or custom chaincode passing '/Channel/Application/...' paths; case mismatch like 'admins' or 'ADMIN'; config using custom local policy names not supported by the getter.","solutions":["Pass exactly the string \"Admins\" or \"Members\" (matching constants policy.Admins / policy.Members) to the channelless check API","Use channel-aware CheckPolicy (with channelID) if you need channel policies like Writers/Readers — channelless local checks only support Admins/Members","Check for case/typo errors: the match is exact and case-sensitive"],"exampleFix":"// before\nerr := checker.CheckPolicyNoChannelBySignedData(\"/Channel/Application/Admins\", signedData)\n// after\nerr := checker.CheckPolicyNoChannelBySignedData(\"Admins\", signedData) // or policy.Admins","handlingStrategy":"validation","validationCode":"var validLocalRoles = map[string]bool{\"Admins\": true, \"Members\": true}\nfunc validateLocalRole(role string) error {\n    if !validLocalRoles[role] {\n        return fmt.Errorf(\"role %q not supported for channelless local check; use Admins or Members\", role)\n    }\n    return nil\n}","typeGuard":"func isSupportedLocalRole(role string) bool {\n    return role == \"Admins\" || role == \"Members\"\n}","tryCatchPattern":"if err := checker.CheckPolicyNoChannelBySignedData(policyName, signedData); err != nil {\n    if strings.Contains(err.Error(), \"not recognized\") {\n        return fmt.Errorf(\"invalid local policy name %q: use Admins or Members\", policyName)\n    }\n    return err\n}","preventionTips":["Reference the exported constants policy.Admins / policy.Members instead of raw strings","Never pass channel policy paths like /Channel/Application/Admins to channelless APIs","Match case exactly: 'admins' is rejected","Use the channel-based CheckPolicy for Writers/Readers/channel policies"],"tags":["hyperledger-fabric","msp","policy","invalid-argument"],"backgroundTag":"unknown-policy-role","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"}