{"record":{"id":"bccd5dce4d3600ef","repo":"hyperledger/fabric","slug":"chaincodespec-s-path-cannot-be-empty","errorCode":null,"errorMessage":"ChaincodeSpec's path cannot be empty","messagePattern":"ChaincodeSpec's path cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/java/platform.go","lineNumber":95,"sourceCode":"\t\t//      ISREG      == 0100000\n\t\t//      -rw-rw-rw- == 0666\n\t\t//\n\t\t// Anything else is suspect in this context and will be rejected\n\t\t// --------------------------------------------------------------------------------------\n\t\tif header.Mode&^0o100666 != 0 {\n\t\t\treturn fmt.Errorf(\"illegal file mode detected for file %s: %o\", header.Name, header.Mode)\n\t\t}\n\t}\n\treturn nil\n}\n\n// WritePackage writes the java chaincode package\nfunc (p *Platform) GetDeploymentPayload(path string) ([]byte, error) {\n\tlogger.Debugf(\"Packaging java project from path %s\", path)\n\n\tif path == \"\" {\n\t\tlogger.Error(\"ChaincodeSpec's path cannot be empty\")\n\t\treturn nil, errors.New(\"ChaincodeSpec's path cannot be empty\")\n\t}\n\n\t// trim trailing slash if it exists\n\tif path[len(path)-1] == '/' {\n\t\tpath = path[:len(path)-1]\n\t}\n\n\tbuf := &bytes.Buffer{}\n\tgw := gzip.NewWriter(buf)\n\ttw := tar.NewWriter(gw)\n\n\texcludedDirs := []string{\"target\", \"build\", \"out\"}\n\texcludedFileTypes := map[string]bool{\".class\": true}\n\terr := util.WriteFolderToTarPackage(tw, path, excludedDirs, nil, excludedFileTypes)\n\tif err != nil {\n\t\tlogger.Errorf(\"Error writing java project to tar package %s\", err)\n\t\treturn nil, fmt.Errorf(\"failed to create chaincode package: %s\", err)\n\t}","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/java/platform.go#L77-L113","documentation":"A guard in the Java platform's GetDeploymentPayload: it rejects the packaging request when the ChaincodeSpec path argument is an empty string, so there is no directory to walk for the java project. The input at fault is the chaincode path supplied to the deploy/package command.","triggerScenarios":"Calling GetDeploymentPayload(\"\") — typically when the ChaincodeSpec in an install/deploy request omitted the chaincode path field.","commonSituations":"A client (SDK, CLI) constructing the install request without setting Path; a config file with an empty chaincode.path value; a template that failed to fill in the path field.","solutions":["Set the chaincode path in the ChaincodeSpec/deploy request to the Java project root","Fix client/CLI flags so the chaincode path is actually passed","Check your configuration/templating for a dropped or empty path value"],"exampleFix":"// before\nspec := &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: \"mycc\"}} // Path missing\npayload, err := platform.GetDeploymentPayload(spec.ChaincodeId.Path)\n// after\nspec := &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: \"mycc\", Path: \"src/chaincode/java/mycc\"}}\npayload, err := platform.GetDeploymentPayload(spec.ChaincodeId.Path)","handlingStrategy":"validation","validationCode":"func safeGetPayload(p *javaPlatform, path string) ([]byte, error) {\n    if strings.TrimSpace(path) == \"\" { return nil, errors.New(\"chaincode path must be set before packaging\") }\n    return p.GetDeploymentPayload(path)\n}","typeGuard":null,"tryCatchPattern":"payload, err := platform.GetDeploymentPayload(path)\nif err != nil && err.Error() == \"ChaincodeSpec's path cannot be empty\" {\n    // surface a config error: the deploy request lacked a path\n}","preventionTips":["Validate ChaincodeSpec.ChaincodeId.Path is non-empty at request construction","Add config-file checks for empty chaincode path values","Fail fast in client SDK wrappers when path is blank"],"tags":["chaincode","java","packaging","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"}