{"record":{"id":"2cc41a0cd4dc0339","repo":"hyperledger/fabric","slug":"unsupported-policy-type-t","errorCode":null,"errorMessage":"unsupported policy type %T","messagePattern":"unsupported policy type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/policy/application.go","lineNumber":161,"sourceCode":"\t}\n\n\treturn p.EvaluateSignedData(signatureSet)\n}\n\nfunc (a *ApplicationPolicyEvaluator) Evaluate(policyBytes []byte, signatureSet []*protoutil.SignedData) error {\n\tp := &peer.ApplicationPolicy{}\n\terr := proto.Unmarshal(policyBytes, p)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to unmarshal ApplicationPolicy bytes\")\n\t}\n\n\tswitch policy := p.Type.(type) {\n\tcase *peer.ApplicationPolicy_SignaturePolicy:\n\t\treturn a.evaluateSignaturePolicy(policy.SignaturePolicy, signatureSet)\n\tcase *peer.ApplicationPolicy_ChannelConfigPolicyReference:\n\t\treturn a.evaluateChannelConfigPolicyReference(policy.ChannelConfigPolicyReference, signatureSet)\n\tdefault:\n\t\treturn errors.Errorf(\"unsupported policy type %T\", policy)\n\t}\n}\n","sourceCodeStart":143,"sourceCodeEnd":164,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/policy/application.go#L143-L164","documentation":"After unmarshalling peer.ApplicationPolicy, Evaluate switches on which Type variant is set. If neither SignaturePolicy nor ChannelConfigPolicyReference is populated (unknown/empty oneof variant), it errors with 'unsupported policy type'.","triggerScenarios":"Evaluating an ApplicationPolicy message with Type nil (empty message) or a oneof variant added in a newer Fabric version that this peer does not understand.","commonSituations":"Building ApplicationPolicy structs but forgetting to set the Type field, forwarding policies produced by a newer Fabric release to an older peer, or proto decode of an unknown oneof case being dropped.","solutions":["Set one of the Type variants when constructing the policy: ApplicationPolicy_SignaturePolicy or ApplicationPolicy_ChannelConfigPolicyReference","Validate the policy has a Type set before submitting/storing it (fail fast at construction time)","Align Fabric versions — a policy from a newer Fabric peer with a new oneof case cannot be evaluated by an older peer","Check that the serialization round-trip preserved the oneof (some generic proto tooling drops it)"],"exampleFix":"// before\npolicy := &peer.ApplicationPolicy{} // Type never set\nerr := evaluator.Evaluate(mustMarshal(policy), sigData)\n// after\npolicy := &peer.ApplicationPolicy{Type: &peer.ApplicationPolicy_ChannelConfigPolicyReference{\n    ChannelConfigPolicyReference: \"/Channel/Application/Endorsement\"}}\nerr := evaluator.Evaluate(mustMarshal(policy), sigData)","handlingStrategy":"type-guard","validationCode":"func validApplicationPolicy(p *peer.ApplicationPolicy) error {\n    switch p.GetType().(type) {\n    case *peer.ApplicationPolicy_SignaturePolicy, *peer.ApplicationPolicy_ChannelConfigPolicyReference:\n        return nil\n    default:\n        return errors.New(\"ApplicationPolicy.Type must be SignaturePolicy or ChannelConfigPolicyReference\")\n    }\n}","typeGuard":"func hasPolicyType(p *peer.ApplicationPolicy) bool {\n    return p.GetType() != nil\n}","tryCatchPattern":"if err := evaluator.Evaluate(policyBytes, sigData); err != nil {\n    var unsupported bool\n    if strings.Contains(err.Error(), \"unsupported policy type\") { unsupported = true }\n    if unsupported {\n        // rebuild policy with a supported Type or upgrade peer\n    }\n    return err\n}","preventionTips":["Always set the Type oneof when constructing ApplicationPolicy structs","Validate policies at creation/persistence time, not only at evaluation time","Keep peer and SDK/CLI Fabric versions aligned to avoid unknown oneof cases"],"tags":["hyperledger-fabric","policy","oneof","unsupported-type"],"backgroundTag":"unsupported-policy-type","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"}