{"record":{"id":"c81a3fb546b24d14","repo":"hyperledger/fabric","slug":"specifying-parameter-sequence-is-invalid-without","errorCode":null,"errorMessage":"Specifying parameter 'sequence' is invalid without parameter 'name'. Rerun the command with -n flag","messagePattern":"Specifying parameter 'sequence' is invalid without parameter 'name'\\. Rerun the command with -n flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/queryapproved.go","lineNumber":208,"sourceCode":"func (a *ApprovedQuerier) printSingleApprovedChaincodeDefinition(acd ApprovedChaincodeDefinition) {\n\tvar packageID string\n\tif acd.GetSource() != nil {\n\t\tswitch source := acd.GetSource().Type.(type) {\n\t\tcase *lb.ChaincodeSource_LocalPackage:\n\t\t\tpackageID = source.LocalPackage.PackageId\n\t\tcase *lb.ChaincodeSource_Unavailable_:\n\t\t}\n\t}\n\tfmt.Fprintf(a.Writer, \"sequence: %d, version: %s, init-required: %t, package-id: %s, endorsement plugin: %s, validation plugin: %s\",\n\t\tacd.GetSequence(), acd.GetVersion(), acd.GetInitRequired(), packageID, acd.GetEndorsementPlugin(), acd.GetValidationPlugin())\n}\n\nfunc (a *ApprovedQuerier) validateInput() error {\n\tif a.Input.ChannelID == \"\" {\n\t\treturn errors.New(\"The required parameter 'channelID' is empty. Rerun the command with -C flag\")\n\t}\n\tif a.Input.Name == \"\" && a.Input.Sequence != 0 {\n\t\treturn errors.New(\"Specifying parameter 'sequence' is invalid without parameter 'name'. Rerun the command with -n flag\")\n\t}\n\n\treturn nil\n}\n\nfunc (a *ApprovedQuerier) createProposal() (*pb.Proposal, error) {\n\tvar function string\n\tvar args proto.Message\n\n\tif a.Input.Name != \"\" {\n\t\tfunction = \"QueryApprovedChaincodeDefinition\"\n\t\targs = &lb.QueryApprovedChaincodeDefinitionArgs{\n\t\t\tName:     a.Input.Name,\n\t\t\tSequence: a.Input.Sequence,\n\t\t}\n\t} else {\n\t\tfunction = \"QueryApprovedChaincodeDefinitions\"\n\t\targs = &lb.QueryApprovedChaincodeDefinitionsArgs{}","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/queryapproved.go#L190-L226","documentation":"ApprovedQuerier.validateInput rejects specifying a sequence number without a chaincode name. Sequence alone is ambiguous because sequence numbers are scoped per chaincode name; the peer's QueryApprovedChaincodeDefinitions request requires a name when filtering by sequence. The message directs the user to add the -n flag.","triggerScenarios":"Running `peer lifecycle chaincode queryapproved -C mychannel -s 1` (sequence set) while Input.Name is empty.","commonSituations":"Copying a command that also queried committed definitions (where sequence alone is valid) instead of queryapproved, or building Input programmatically and setting Sequence without Name.","solutions":["Add the -n flag: `peer lifecycle chaincode queryapproved -C mychannel -n mycc -s 1`","Or drop the -s flag to list all approved definitions on the channel","In client code, only set Input.Sequence when Input.Name is also set"],"exampleFix":"// before\npeer lifecycle chaincode queryapproved -C mychannel -s 1\n// after\npeer lifecycle chaincode queryapproved -C mychannel -n mycc -s 1","handlingStrategy":"validation","validationCode":"if name == \"\" && sequence != 0 {\n\treturn errors.New(\"Specifying parameter 'sequence' is invalid without parameter 'name'. Rerun the command with -n flag\")\n}","typeGuard":null,"tryCatchPattern":"if err := q.Query(); err != nil {\n\tif strings.Contains(err.Error(), \"'sequence'\") {\n\t\tfmt.Fprintln(os.Stderr, \"Usage: -s requires -n <chaincodeName>\")\n\t}\n\treturn err\n}","preventionTips":["Never combine -s without -n on queryapproved","Validate flag pairs (name/sequence) in scripts before running the command","When populating Input programmatically, enforce Name != \"\" whenever Sequence != 0","Remember querycommitted and queryapproved have different flag requirements"],"tags":["hyperledger-fabric","cli","input-validation"],"backgroundTag":"missing-required-argument","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"}