{"record":{"id":"145ad61274e75524","repo":"hyperledger/fabric","slug":"trailing-args-detected-145ad6","errorCode":null,"errorMessage":"trailing args detected","messagePattern":"trailing args detected","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/version/version.go","lineNumber":31,"sourceCode":"\t\"github.com/hyperledger/fabric/common/metadata\"\n\t\"github.com/spf13/cobra\"\n)\n\n// Program name\nconst ProgramName = \"peer\"\n\n// Cmd returns the Cobra Command for Version\nfunc Cmd() *cobra.Command {\n\treturn cobraCommand\n}\n\nvar cobraCommand = &cobra.Command{\n\tUse:   \"version\",\n\tShort: \"Print fabric peer version.\",\n\tLong:  `Print current version of the fabric peer server.`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif len(args) != 0 {\n\t\t\treturn fmt.Errorf(\"trailing args detected\")\n\t\t}\n\t\t// Parsing of the command line is done so silence cmd usage\n\t\tcmd.SilenceUsage = true\n\t\tfmt.Print(GetInfo())\n\t\treturn nil\n\t},\n}\n\n// GetInfo returns version information for the peer\nfunc GetInfo() string {\n\tccinfo := fmt.Sprintf(\"  Base Docker Label: %s\\n\"+\n\t\t\"  Docker Namespace: %s\\n\",\n\t\tmetadata.BaseDockerLabel,\n\t\tmetadata.DockerNamespace)\n\n\treturn fmt.Sprintf(\"%s:\\n Version: %s\\n Commit SHA: %s\\n Go version: %s\\n\"+\n\t\t\" OS/Arch: %s\\n\"+\n\t\t\" Chaincode:\\n%s\\n\",","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/version/version.go#L13-L49","documentation":"The 'peer version' command takes no positional arguments. Its cobra RunE checks len(args) != 0 and returns 'trailing args detected' when anything follows the subcommand, preventing users from unknowingly passing ignored arguments.","triggerScenarios":"Running 'peer version <anything>' such as 'peer version --short extra', 'peer version 1.0', or pasting extra tokens after 'version'.","commonSituations":"Confusing 'peer version' with 'peer chaincode version'-style subcommands; shell scripts appending flags meant for other commands; typos leaving stray tokens in the command line.","solutions":["Run the command bare: peer version (no extra args).","Use the built-in -s/--short or -o/--output flags instead of positional arguments.","Fix scripts that append tokens after 'peer version'."],"exampleFix":"// before\npeer version extra-arg\n// after\npeer version","handlingStrategy":"validation","validationCode":"// in scripts invoking version programmatically\nargs := []string{\"version\"}\nif len(extraArgs) > 0 { return fmt.Errorf(\"peer version takes no positional args\") }\ncmd := exec.Command(\"peer\", append(args, extraArgs...)...)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run 'peer version' with no positional arguments","Use -s (short) or -o (output format) flags instead of extra tokens","Trim trailing whitespace/tokens when building command lines in scripts"],"tags":["cli","cobra","argument-validation","fabric"],"backgroundTag":"unexpected-cli-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"}