{"record":{"id":"311bb2020bde80fe","repo":"hyperledger/fabric","slug":"cannot-specify-both-signature-policy-and-ch","errorCode":null,"errorMessage":"cannot specify both \"--signature-policy\" and \"--channel-config-policy\"","messagePattern":"cannot specify both \"--signature-policy\" and \"--channel-config-policy\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/chaincode/common.go","lineNumber":250,"sourceCode":"\t\t}\n\n\t\tccarray = append(ccarray, cc)\n\t}\n\n\tccp := &pb.CollectionConfigPackage{Config: ccarray}\n\tccpBytes, err := proto.Marshal(ccp)\n\treturn ccp, ccpBytes, err\n}\n\nfunc getApplicationPolicy(signaturePolicy, channelConfigPolicy string) (*pb.ApplicationPolicy, error) {\n\tif signaturePolicy == \"\" && channelConfigPolicy == \"\" {\n\t\t// no policy, no problem\n\t\treturn nil, nil\n\t}\n\n\tif signaturePolicy != \"\" && channelConfigPolicy != \"\" {\n\t\t// mo policies, mo problems\n\t\treturn nil, errors.New(`cannot specify both \"--signature-policy\" and \"--channel-config-policy\"`)\n\t}\n\n\tvar applicationPolicy *pb.ApplicationPolicy\n\tif signaturePolicy != \"\" {\n\t\tsignaturePolicyEnvelope, err := policydsl.FromString(signaturePolicy)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Errorf(\"invalid signature policy: %s\", signaturePolicy)\n\t\t}\n\n\t\tapplicationPolicy = &pb.ApplicationPolicy{\n\t\t\tType: &pb.ApplicationPolicy_SignaturePolicy{\n\t\t\t\tSignaturePolicy: signaturePolicyEnvelope,\n\t\t\t},\n\t\t}\n\t}\n\n\tif channelConfigPolicy != \"\" {\n\t\tapplicationPolicy = &pb.ApplicationPolicy{","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/chaincode/common.go#L232-L268","documentation":"getApplicationPolicy builds an ApplicationPolicy from user-supplied policy flags and refuses to proceed when both a signature policy (--signature-policy) and a channel config policy (--channel-config-policy) are specified, since a single policy reference must be unambiguous. The library throws this plain error to force the user to choose exactly one policy style.","triggerScenarios":"Invoking peer CLI commands (e.g. approveformyorg) or building collection configs via getCollectionConfigFromBytes with both --signature-policy and --channel-config-policy flags set to non-empty values.","commonSituations":"Copy-pasting a command example that had --signature-policy and appending --channel-config-policy from another example; scripts accumulating flags across edits; users trying to 'combine' an implicit policy with an explicit one.","solutions":["Remove either the --signature-policy or the --channel-config-policy flag; keep only one","If you need a signature policy, delete the --channel-config-policy flag (and vice versa)","Review the constructed command in your script/CI to ensure only one policy flag is populated"],"exampleFix":"// before\npeer chaincode approveformyorg -C mychannel --signature-policy \"OR('Org1MSP.member')\" --channel-config-policy /Channel/Application/Endorsement\n// after\npeer chaincode approveformyorg -C mychannel --signature-policy \"OR('Org1MSP.member')\"","handlingStrategy":"validation","validationCode":"func validatePolicyFlags(signaturePolicy, channelConfigPolicy string) error {\n\tif signaturePolicy != \"\" && channelConfigPolicy != \"\" {\n\t\treturn errors.New(\"specify only one of --signature-policy or --channel-config-policy\")\n\t}\n\treturn nil\n}","typeGuard":"func hasExclusivePolicy(sp, ccp string) bool { return (sp == \"\") != (ccp == \"\") || (sp == \"\" && ccp == \"\") }","tryCatchPattern":"if err := validatePolicyFlags(sigPolicy, chanPolicy); err != nil {\n\treturn fmt.Errorf(\"usage fix: keep exactly one policy flag: %w\", err)\n}","preventionTips":["Build commands programmatically, setting only one policy field","Grep scripts for both flags co-occurring in one command","Document your team standard (signature-policy vs channel policy) and lint for it"],"tags":["cli","chaincode","policy","fabric"],"backgroundTag":"conflicting-flags","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"}