{"record":{"id":"3bb7d36c72bb29b5","repo":"hyperledger/fabric","slug":"chaincode-install-package-must-be-provided","errorCode":null,"errorMessage":"chaincode install package must be provided","messagePattern":"chaincode install package must be provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/calculatepackageid.go","lineNumber":45,"sourceCode":"\tWriter  io.Writer\n}\n\n// CalculatePackageIDInput holds the input parameters for calculating\n// the package ID of a packaged chaincode\ntype CalculatePackageIDInput struct {\n\tPackageFile  string\n\tOutputFormat string\n}\n\n// CalculatePackageIDOutput holds the JSON output format\ntype CalculatePackageIDOutput struct {\n\tPackageID string `json:\"package_id\"`\n}\n\n// Validate checks that the required parameters are provided\nfunc (i *CalculatePackageIDInput) Validate() error {\n\tif i.PackageFile == \"\" {\n\t\treturn errors.New(\"chaincode install package must be provided\")\n\t}\n\n\treturn nil\n}\n\n// CalculatePackageIDCmd returns the cobra command for calculating\n// the package ID for a packaged chaincode\nfunc CalculatePackageIDCmd(p *PackageIDCalculator) *cobra.Command {\n\tcalculatePackageIDCmd := &cobra.Command{\n\t\tUse:       \"calculatepackageid [packageFile]\",\n\t\tShort:     \"Calculate the package ID for a chaincode.\",\n\t\tLong:      \"Calculate the package ID for a packaged chaincode.\",\n\t\tValidArgs: []string{\"1\"},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif p == nil {\n\t\t\t\tp = &PackageIDCalculator{\n\t\t\t\t\tReader: &persistence.FilesystemIO{},\n\t\t\t\t\tWriter: os.Stdout,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/calculatepackageid.go#L27-L63","documentation":"CalculatePackageIDInput.Validate enforces that a packaged chaincode tarball (--package-file) was supplied before the calculatepackageid command does any work. The command computes a package ID from an install package file, so without the file path there is nothing to hash. This is a pure input-validation error raised before any file I/O.","triggerScenarios":"Running `peer lifecycle chaincode calculatepackageid` without the --package-file flag, or programmatically constructing CalculatePackageIDInput with PackageFile left as empty string and calling Validate().","commonSituations":"Copy-pasting a command example and dropping the --package-file flag; scripting where the packaged .tgz path variable is empty because a prior `package` step failed or the variable wasn't exported.","solutions":["Add --package-file pointing to the packaged chaincode tarball produced by `peer lifecycle chaincode package`, e.g. mycc_1.0.tgz.","In Go, set CalculatePackageIDInput.PackageFile to the full path of the .tgz before calling Validate().","Confirm the packaging step succeeded and the file exists at the given path before invoking calculatepackageid."],"exampleFix":"// before\npeer lifecycle chaincode calculatepackageid\n// after\npeer lifecycle chaincode calculatepackageid --package-file ./mycc_1.0.tgz","handlingStrategy":"validation","validationCode":"info := chaincode.CalculatePackageIDInput{}\nif info.PackageFile == \"\" {\n    return errors.New(\"pass --package-file pointing to the packaged .tgz\")\n}\nif _, err := os.Stat(info.PackageFile); err != nil {\n    return fmt.Errorf(\"package file missing: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := info.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"must be provided\") {\n        return flag.ErrHelp // print usage so the operator sees the required flag\n    }\n    return err\n}","preventionTips":["Always run `peer lifecycle chaincode package` first and capture the .tgz path.","Use absolute paths for --package-file in scripts.","Check file existence before invoking the command in CI pipelines."],"tags":["fabric","cli-input-validation","missing-argument"],"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"}