{"record":{"id":"d878c9a3aaaa402b","repo":"hyperledger/fabric","slug":"policy-name-s-type-t-is-not-convertible-to","errorCode":null,"errorMessage":"policy (name='%s',type='%T') is not convertible to SignaturePolicyEnvelope","messagePattern":"policy \\(name='(.+?)',type='%T'\\) is not convertible to SignaturePolicyEnvelope","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/policies/policy.go","lineNumber":316,"sourceCode":"\t\tdefer logger.Debugf(\"== Done Evaluating %T Policy %s\", pl.Policy, pl.policyName)\n\t}\n\n\terr := pl.Policy.EvaluateIdentities(identities)\n\tif err != nil {\n\t\tlogger.Debugf(\"Signature set did not satisfy policy %s\", pl.policyName)\n\t} else {\n\t\tlogger.Debugf(\"Signature set satisfies policy %s\", pl.policyName)\n\t}\n\treturn err\n}\n\nfunc (pl *PolicyLogger) Convert() (*cb.SignaturePolicyEnvelope, error) {\n\tlogger.Debugf(\"== Converting %T Policy %s ==\", pl.Policy, pl.policyName)\n\n\tconvertiblePolicy, ok := pl.Policy.(Converter)\n\tif !ok {\n\t\tlogger.Errorf(\"policy (name='%s',type='%T') is not convertible to SignaturePolicyEnvelope\", pl.policyName, pl.Policy)\n\t\treturn nil, errors.Errorf(\"policy (name='%s',type='%T') is not convertible to SignaturePolicyEnvelope\", pl.policyName, pl.Policy)\n\t}\n\n\tcp, err := convertiblePolicy.Convert()\n\tif err != nil {\n\t\tlogger.Errorf(\"== Error Converting %T Policy %s, err %s\", pl.Policy, pl.policyName, err.Error())\n\t} else {\n\t\tlogger.Debugf(\"== Done Converting %T Policy %s\", pl.Policy, pl.policyName)\n\t}\n\n\treturn cp, err\n}\n\n// GetPolicy returns a policy and true if it was the policy requested, or false if it is the default reject policy\nfunc (pm *ManagerImpl) GetPolicy(id string) (Policy, bool) {\n\tif id == \"\" {\n\t\tlogger.Errorf(\"Returning dummy reject all policy because no policy ID supplied\")\n\t\treturn rejectPolicy(id), false\n\t}","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/policies/policy.go#L298-L334","documentation":"PolicyLogger.Convert converts a policy back into a SignaturePolicyEnvelope for signature collection (e.g. building config signatures). If the wrapped policy does not implement the Converter interface, conversion is impossible and this error names the policy and its concrete Go type.","triggerScenarios":"Calling Convert on a PolicyLogger whose underlying Policy is not convertible (e.g. a rejectPolicy placeholder from GetPolicy on a missing name, or a custom policy type without a Convert method).","commonSituations":"Attempting to pre-sign a config update using a policy that resolved to the reject sentinel; custom policy implementations that do not implement Converter; invoking conversion on implicit policies whose sub-policies are unconvertible.","solutions":["Only call Convert on policies known to implement Converter (signature-type policies built from a SignaturePolicyEnvelope)","Check policy existence first so rejectPolicy is never converted","Implement Convert() on custom policy types if conversion must be supported"],"exampleFix":"// before\np, _ := mgr.GetPolicy(\"Missing\")\nenv, err := p.(*policies.PolicyLogger).Convert() // not convertible\n// after\nif c, ok := p.(policies.Converter); ok {\n  env, err := c.Convert()\n}","handlingStrategy":"type-guard","validationCode":"// Verify the policy exists and is a signature policy before converting\nif _, ok := mgr.Manager(nil); !ok { return errors.New(\"no manager\") }\np, _ := mgr.GetPolicy(name)\n_ = p","typeGuard":"func asConverter(p policies.Policy) (policies.Converter, bool) {\n  c, ok := p.(policies.Converter)\n  return c, ok\n}","tryCatchPattern":"env, err := policyLogger.Convert()\nif err != nil && strings.Contains(err.Error(), \"is not convertible\") {\n  return fmt.Errorf(\"cannot sign against policy %s: not a signature policy\", name)\n}","preventionTips":["Only convert policies you know were built from SignaturePolicyEnvelopes","Guard with a Converter interface assertion before calling Convert","Avoid converting rejectPolicy placeholders returned for missing names"],"tags":["hyperledger-fabric","policy-conversion","type-assertion"],"backgroundTag":"policy-not-convertible","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"}