{"record":{"id":"19d0a8975d69c2d1","repo":"hyperledger/fabric","slug":"package-label-must-be-specified","errorCode":null,"errorMessage":"package label must be specified","messagePattern":"package label must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/package.go","lineNumber":60,"sourceCode":"\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\"},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif p == nil {\n\t\t\t\tpr := packaging.NewRegistry(packaging.SupportedPlatforms...)","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/package.go#L42-L78","documentation":"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).","triggerScenarios":"Running `peer lifecycle chaincode package` without --label, or with an empty $CC_LABEL variable.","commonSituations":"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.","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."],"exampleFix":"// before\npeer lifecycle chaincode package basic.tar.gz --path . --lang golang\n// error: package label must be specified\n// after\npeer lifecycle chaincode package basic.tar.gz --path . --lang golang --label basic_1.0","handlingStrategy":"validation","validationCode":"#!/bin/bash\n: \"${LABEL:?Set LABEL e.g. mycc_1.0}\"\ncase \"$LABEL\" in\n  *[[:space:]]*) echo \"LABEL must not contain whitespace\"; exit 1 ;;\nesac\npeer lifecycle chaincode package \"$OUT\" --path \"$CC_SRC_PATH\" --lang \"$CC_LANG\" --label \"$LABEL\"","typeGuard":null,"tryCatchPattern":"if ! out=$(peer lifecycle chaincode package \"$OUT\" --path \"$P\" --lang \"$L\" --label \"$LABEL\" 2>&1); then\n  case \"$out\" in\n    *\"package label must be specified\"*) echo \"Add --label <name>_<version>\"; exit 2 ;;\n    *) echo \"$out\"; exit 1 ;;\n  esac\nfi","preventionTips":["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."],"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"}