hyperledger/fabric · error
The required parameter 'package-id' is empty. Rerun the comm
Error message
The required parameter 'package-id' is empty. Rerun the command with --package-id flag
What it means
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.
Source
Thrown at internal/peer/lifecycle/chaincode/getinstalledpackage.go:45
type InstalledPackageGetter struct {
Command *cobra.Command
Input *GetInstalledPackageInput
EndorserClient EndorserClient
Signer Signer
Writer Writer
}
// GetInstalledPackageInput holds all of the input parameters for
// getting an installed chaincode package from a peer.
type GetInstalledPackageInput struct {
PackageID string
OutputDirectory string
}
// Validate checks that the required parameters are provided.
func (i *GetInstalledPackageInput) Validate() error {
if i.PackageID == "" {
return errors.New("The required parameter 'package-id' is empty. Rerun the command with --package-id flag")
}
return nil
}
// GetInstalledPackageCmd returns the cobra command for getting an
// installed chaincode package from a peer.
func GetInstalledPackageCmd(i *InstalledPackageGetter, cryptoProvider bccsp.BCCSP) *cobra.Command {
chaincodeGetInstalledPackageCmd := &cobra.Command{
Use: "getinstalledpackage [outputfile]",
Short: "Get an installed chaincode package from a peer.",
Long: "Get an installed chaincode package from a peer.",
RunE: func(cmd *cobra.Command, args []string) error {
if i == nil {
ccInput := &ClientConnectionsInput{
CommandName: cmd.Name(),
EndorserRequired: true,
PeerAddresses: peerAddresses,View on GitHub (pinned to 2736b63f8f)
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)
Example fix
// before peer lifecycle chaincode getinstalledpackage --output-dir ./pkgs // after peer lifecycle chaincode getinstalledpackage --package-id basic_1.0:ec4e0b2f... --output-dir ./pkgs
Defensive patterns
Strategy: validation
Validate before calling
if packageID == "" {
return errors.New("--package-id is required; obtain one via peer lifecycle chaincode queryinstalled")
} Try / catch
if err := cmd.Execute(); err != nil {
if strings.Contains(err.Error(), "required parameter 'package-id' is empty") {
// rerun with a valid --package-id
}
} Prevention
- 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
When it happens
Trigger: Running getinstalledpackage without --package-id, or with --package-id pointing to an empty string (e.g. shell variable expansion produced empty).
Common situations: Forgetting the flag entirely; a script variable like $PKG_ID unset/empty; copying the example command without editing.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- fetch target required, oldest, newest, config, or a number
- chaincode install package must be provided
- query iterator not found
- application config does not exist for channel '%s'
- unknown chaincode '%s' for channel '%s'
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/72e511884e67dc75.
Report an issue: GitHub.