{"record":{"id":"c664363a0cae06a7","repo":"hyperledger/fabric","slug":"trailing-args-detected-s-c66436","errorCode":null,"errorMessage":"trailing args detected: %s","messagePattern":"trailing args detected: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/channel/list.go","lineNumber":34,"sourceCode":"\t\"github.com/hyperledger/fabric/core/scc/cscc\"\n\t\"github.com/hyperledger/fabric/protoutil\"\n\t\"github.com/spf13/cobra\"\n\t\"google.golang.org/protobuf/proto\"\n)\n\ntype endorserClient struct {\n\tcf *ChannelCmdFactory\n}\n\nfunc listCmd(cf *ChannelCmdFactory) *cobra.Command {\n\t// Set the flags on the channel start command.\n\treturn &cobra.Command{\n\t\tUse:   \"list\",\n\t\tShort: \"List of channels peer has joined.\",\n\t\tLong:  \"List of channels peer has joined.\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) != 0 {\n\t\t\t\treturn fmt.Errorf(\"trailing args detected: %s\", args)\n\t\t\t}\n\t\t\t// Parsing of the command line is done so silence cmd usage\n\t\t\tcmd.SilenceUsage = true\n\t\t\treturn list(cf)\n\t\t},\n\t}\n}\n\nfunc (cc *endorserClient) getChannels() ([]*pb.ChannelInfo, error) {\n\tvar err error\n\n\tinvocation := &pb.ChaincodeInvocationSpec{\n\t\tChaincodeSpec: &pb.ChaincodeSpec{\n\t\t\tType:        pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[\"GOLANG\"]),\n\t\t\tChaincodeId: &pb.ChaincodeID{Name: \"cscc\"},\n\t\t\tInput:       &pb.ChaincodeInput{Args: [][]byte{[]byte(cscc.GetChannels)}},\n\t\t},\n\t}","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/channel/list.go#L16-L52","documentation":"This is a CLI argument-arity error from the `peer channel list` cobra command. The list subcommand accepts no positional arguments; passing any extra arguments causes RunE to fail before the network call is attempted.","triggerScenarios":"Running `peer channel list` with any positional argument, e.g. `peer channel list mychannel` or `peer channel list -c mychannel extra` — len(args) != 0 in the cobra RunE handler.","commonSituations":"Users habitually append the channel name after the subcommand (as with other tools) instead of using the -c/--channelID flag; copy-paste from `peer channel join` examples which do take an argument; shell scripts carrying stale extra tokens.","solutions":["Remove all positional arguments; pass the channel with -c/--channelID if needed (list ignores it and lists all)","Use `peer channel list --help` to see the accepted flags","Fix scripts to call the bare `peer channel list` command"],"exampleFix":"// before\npeer channel list mychannel\n// after\npeer channel list -c mychannel   # or just: peer channel list","handlingStrategy":"validation","validationCode":"// check usage before invoking\n// peer channel list takes NO positional args\nexec.Command(\"peer\", \"channel\", \"list\", \"-c\", \"mychannel\") // not: \"list\", \"mychannel\"","typeGuard":null,"tryCatchPattern":"RunE: func(cmd *cobra.Command, args []string) error {\n    if len(args) != 0 {\n        return fmt.Errorf(\"trailing args detected: %s\", args)\n    }\n    ...\n}","preventionTips":["Never append a channel name after `peer channel list`; use -c","Run --help to confirm accepted flags for each subcommand","Lint shell scripts that mix join/list/joinbysnapshot invocations"],"tags":["cli","cobra","arguments","fabric"],"backgroundTag":"trailing-args-detected","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"}