{"record":{"id":"e4dcd75f7f815d1e","repo":"hyperledger/fabric","slug":"output-file-must-be-specified","errorCode":null,"errorMessage":"output file must be specified","messagePattern":"output file must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/package.go","lineNumber":57,"sourceCode":"// PackageInput holds the input parameters for packaging a\n// ChaincodeInstallPackage\ntype PackageInput struct {\n\tOutputFile string\n\tPath       string\n\tType       string\n\tLabel      string\n}\n\n// Validate checks for the required inputs\nfunc (p *PackageInput) Validate() error {\n\tif p.Path == \"\" {\n\t\treturn errors.New(\"chaincode path must be specified\")\n\t}\n\tif p.Type == \"\" {\n\t\treturn errors.New(\"chaincode language must be specified\")\n\t}\n\tif p.OutputFile == \"\" {\n\t\treturn errors.New(\"output file must be specified\")\n\t}\n\tif p.Label == \"\" {\n\t\treturn errors.New(\"package label must be specified\")\n\t}\n\tif err := persistence.ValidateLabel(p.Label); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// PackageCmd returns the cobra command for packaging chaincode\nfunc PackageCmd(p *Packager) *cobra.Command {\n\tchaincodePackageCmd := &cobra.Command{\n\t\tUse:       \"package [outputfile]\",\n\t\tShort:     \"Package a chaincode\",\n\t\tLong:      \"Package a chaincode and write the package to a file.\",\n\t\tValidArgs: []string{\"1\"},","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/package.go#L39-L75","documentation":"PackageInput.Validate returns this when no output file argument was provided to the package command. The output file is the .tar.gz chaincode package path that the command writes; without it there is nothing to write to.","triggerScenarios":"Running `peer lifecycle chaincode package` with zero positional args (caught earlier by PackageChaincode's arg count check) or with --output-file style input left empty when setInput was bypassed, e.g. programmatic use of the PackageInput struct.","commonSituations":"Programmatic callers constructing PackageInput directly without OutputFile; wrapped CLI tools that forward args incorrectly; templates where the output filename variable was empty.","solutions":["Pass exactly one positional arg: peer lifecycle chaincode package ./basic_1.0.tar.gz --path ... --lang ... --label ...","If constructing PackageInput programmatically, set OutputFile to a writable path before calling Validate/Package.","Check the path is writable by the invoking user to avoid the follow-up write failure (error writing chaincode package to %s)."],"exampleFix":"// before\np := &PackageInput{Path: path, Type: \"go\", Label: label}\n// after\np := &PackageInput{Path: path, Type: \"go\", Label: label, OutputFile: \"./mycc_1.0.tar.gz\"}\nif err := p.Validate(); err != nil {\n    return err\n}","handlingStrategy":"validation","validationCode":"#!/bin/bash\nOUT=\"${1:-}\"\n[ -n \"$OUT\" ] || { echo \"usage: package <output-file.tar.gz>\"; exit 1; }\npeer lifecycle chaincode package \"$OUT\" --path \"$CC_SRC_PATH\" --lang \"$CC_LANG\" --label \"$LABEL\"","typeGuard":null,"tryCatchPattern":"if ! out=$(peer lifecycle chaincode package \"$OUT\" ... 2>&1); then\n  case \"$out\" in\n    *\"output file must be specified\"*) echo \"Pass exactly one positional arg: <output .tar.gz path>\"; exit 2 ;;\n    *) echo \"$out\"; exit 1 ;;\n  esac\nfi","preventionTips":["Always supply exactly one positional output filename.","Choose an output path inside a pre-created, writable directory.","If calling PackageInput programmatically, set OutputFile before Validate.","Verify writability with touch \"$(dirname \"$OUT\")/.wtest\" first."],"tags":["hyperledger-fabric","cli","validation","missing-flag"],"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"}