hyperledger/fabric · error
package label must be specified
Error message
package label must be specified
What it means
PackageInput.Validate returns this when the --label flag is empty. The label is a human-readable identifier stored in the package metadata and later used in approveformyorg/commit and the CheckCommitReadiness calculations. Fabric requires a non-empty label and one satisfying persistence.ValidateLabel (no whitespace/invalid characters).
Source
Thrown at internal/peer/lifecycle/chaincode/package.go:60
OutputFile string
Path string
Type string
Label string
}
// Validate checks for the required inputs
func (p *PackageInput) Validate() error {
if p.Path == "" {
return errors.New("chaincode path must be specified")
}
if p.Type == "" {
return errors.New("chaincode language must be specified")
}
if p.OutputFile == "" {
return errors.New("output file must be specified")
}
if p.Label == "" {
return errors.New("package label must be specified")
}
if err := persistence.ValidateLabel(p.Label); err != nil {
return err
}
return nil
}
// PackageCmd returns the cobra command for packaging chaincode
func PackageCmd(p *Packager) *cobra.Command {
chaincodePackageCmd := &cobra.Command{
Use: "package [outputfile]",
Short: "Package a chaincode",
Long: "Package a chaincode and write the package to a file.",
ValidArgs: []string{"1"},
RunE: func(cmd *cobra.Command, args []string) error {
if p == nil {
pr := packaging.NewRegistry(packaging.SupportedPlatforms...)View on GitHub (pinned to 2736b63f8f)
Solutions
- Re-run with a label, e.g. --label basic_1.0 (conventionally <name>_<version>).
- Ensure the label has no invalid characters/whitespace; keep to letters, digits, dash, underscore, dot.
- Use the SAME label in the later approveformyorg command; re-package with a fixed label if approval already used another label.
Example fix
// before peer lifecycle chaincode package basic.tar.gz --path . --lang golang // error: package label must be specified // after peer lifecycle chaincode package basic.tar.gz --path . --lang golang --label basic_1.0
Defensive patterns
Strategy: validation
Validate before calling
#!/bin/bash
: "${LABEL:?Set LABEL e.g. mycc_1.0}"
case "$LABEL" in
*[[:space:]]*) echo "LABEL must not contain whitespace"; exit 1 ;;
esac
peer lifecycle chaincode package "$OUT" --path "$CC_SRC_PATH" --lang "$CC_LANG" --label "$LABEL" Try / catch
if ! out=$(peer lifecycle chaincode package "$OUT" --path "$P" --lang "$L" --label "$LABEL" 2>&1); then
case "$out" in
*"package label must be specified"*) echo "Add --label <name>_<version>"; exit 2 ;;
*) echo "$out"; exit 1 ;;
esac
fi Prevention
- Always pass --label; use the convention <chaincodeName>_<version>.
- Reuse the identical label in approveformyorg.
- Guard label variables with ${LABEL:?} in scripts.
- Avoid spaces/special characters in the label.
When it happens
Trigger: Running `peer lifecycle chaincode package` without --label, or with an empty $CC_LABEL variable.
Common situations: CI pipelines that build the label from $VERSION or $CHAINCODE_NAME which were unset; teams omitting the flag because it looks optional; labels with spaces that pass emptiness but then fail persistence.ValidateLabel.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- chaincode path must be specified
- chaincode language must be specified
- output file must be specified
- '%s' not equal <newest|oldest|config|(number)>
- Must supply channel ID
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/19d0a8975d69c2d1.
Report an issue: GitHub.