{"record":{"id":"72e511884e67dc75","repo":"hyperledger/fabric","slug":"the-required-parameter-package-id-is-empty-reru","errorCode":null,"errorMessage":"The required parameter 'package-id' is empty. Rerun the command with --package-id flag","messagePattern":"The required parameter 'package-id' is empty\\. Rerun the command with --package-id flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/getinstalledpackage.go","lineNumber":45,"sourceCode":"type InstalledPackageGetter struct {\n\tCommand        *cobra.Command\n\tInput          *GetInstalledPackageInput\n\tEndorserClient EndorserClient\n\tSigner         Signer\n\tWriter         Writer\n}\n\n// GetInstalledPackageInput holds all of the input parameters for\n// getting an installed chaincode package from a peer.\ntype GetInstalledPackageInput struct {\n\tPackageID       string\n\tOutputDirectory string\n}\n\n// Validate checks that the required parameters are provided.\nfunc (i *GetInstalledPackageInput) Validate() error {\n\tif i.PackageID == \"\" {\n\t\treturn errors.New(\"The required parameter 'package-id' is empty. Rerun the command with --package-id flag\")\n\t}\n\n\treturn nil\n}\n\n// GetInstalledPackageCmd returns the cobra command for getting an\n// installed chaincode package from a peer.\nfunc GetInstalledPackageCmd(i *InstalledPackageGetter, cryptoProvider bccsp.BCCSP) *cobra.Command {\n\tchaincodeGetInstalledPackageCmd := &cobra.Command{\n\t\tUse:   \"getinstalledpackage [outputfile]\",\n\t\tShort: \"Get an installed chaincode package from a peer.\",\n\t\tLong:  \"Get an installed chaincode package from a peer.\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif i == nil {\n\t\t\t\tccInput := &ClientConnectionsInput{\n\t\t\t\t\tCommandName:           cmd.Name(),\n\t\t\t\t\tEndorserRequired:      true,\n\t\t\t\t\tPeerAddresses:         peerAddresses,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/getinstalledpackage.go#L27-L63","documentation":"GetInstalledPackageInput.Validate enforces that --package-id was provided to the 'peer lifecycle chaincode getinstalledpackage' command. The package ID uniquely identifies an installed chaincode package on the peer; without it the command cannot construct the query.","triggerScenarios":"Running getinstalledpackage without --package-id, or with --package-id pointing to an empty string (e.g. shell variable expansion produced empty).","commonSituations":"Forgetting the flag entirely; a script variable like $PKG_ID unset/empty; copying the example command without editing.","solutions":["Run with a package ID obtained from queryinstalled: --package-id <ccname>:<hash>","Fix the empty shell variable in your script (check env/preceding command output)","Verify the flag is spelled --package-id (not --packageID or -p)"],"exampleFix":"// before\npeer lifecycle chaincode getinstalledpackage --output-dir ./pkgs\n// after\npeer lifecycle chaincode getinstalledpackage --package-id basic_1.0:ec4e0b2f... --output-dir ./pkgs","handlingStrategy":"validation","validationCode":"if packageID == \"\" {\n    return errors.New(\"--package-id is required; obtain one via peer lifecycle chaincode queryinstalled\")\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n    if strings.Contains(err.Error(), \"required parameter 'package-id' is empty\") {\n        // rerun with a valid --package-id\n    }\n}","preventionTips":["Capture package IDs from queryinstalled output and pass them explicitly","Fail fast in scripts when PKG_ID variables are empty (set -u / length check)","Remember the exact flag name: --package-id"],"tags":["fabric","cli","missing-argument","lifecycle"],"backgroundTag":"missing-required-flag","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"}