{"record":{"id":"0682b21c0a3a1747","repo":"hyperledger/fabric","slug":"cannot-collect-files-from-empty-chaincode-path","errorCode":null,"errorMessage":"cannot collect files from empty chaincode path","messagePattern":"cannot collect files from empty chaincode path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/golang/platform.go","lineNumber":324,"sourceCode":"// CodeDescriptor describes the code we're packaging.\ntype CodeDescriptor struct {\n\tSource       string // absolute path of the source to package\n\tMetadataRoot string // absolute path META-INF\n\tPath         string // import path of the package\n\tModule       bool   // does this represent a go module\n}\n\nfunc (cd CodeDescriptor) isMetadata(path string) bool {\n\treturn strings.HasPrefix(\n\t\tfilepath.Clean(path),\n\t\tfilepath.Clean(cd.MetadataRoot),\n\t)\n}\n\n// DescribeCode returns GOPATH and package information.\nfunc DescribeCode(path string) (*CodeDescriptor, error) {\n\tif path == \"\" {\n\t\treturn nil, errors.New(\"cannot collect files from empty chaincode path\")\n\t}\n\n\t// Use the module root as the source path for go modules\n\tmodInfo, err := moduleInfo(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif modInfo != nil {\n\t\t// calculate where the metadata should be relative to module root\n\t\trelImport, err := filepath.Rel(modInfo.ModulePath, modInfo.ImportPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn &CodeDescriptor{\n\t\t\tModule:       true,\n\t\t\tMetadataRoot: filepath.Join(modInfo.Dir, relImport, \"META-INF\"),","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/golang/platform.go#L306-L342","documentation":"Returned by golang platform DescribeCode when the chaincode path argument is an empty string. There is no source location to package or validate, so the guard rejects the request before any filesystem access is attempted.","triggerScenarios":"Calling DescribeCode(\"\") directly, or ValidatePath/GetDeploymentPayload on a platform whose path resolved to the empty string (e.g. missing or blank chaincode path in the package or install request).","commonSituations":"Empty 'path' field in chaincode install/instantiate payloads, config defaults not set, stripping a path incorrectly before calling the platform.","solutions":["Provide a non-empty chaincode source path in the deployment spec.","Validate path != \"\" in your client before invoking lifecycle APIs.","Check upstream parsing that may be trimming the path to empty."],"exampleFix":"// before\nplatform.GetDeploymentPayload(\"\", \"\")\n// after\nif ccPath == \"\" { return errors.New(\"chaincode path is required\") }\npayload, err := platform.GetDeploymentPayload(ccPath, \"\")","handlingStrategy":"validation","validationCode":"if ccPath == \"\" {\n\treturn errors.New(\"chaincode path must be non-empty\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := golang.DescribeCode(path); err != nil {\n\tif err.Error() == \"cannot collect files from empty chaincode path\" {\n\t\t// fix the deployment spec's path field\n\t}\n}","preventionTips":["Always populate the path field in install/instantiate requests","Trim and check path strings before calling platform APIs","Add client-side empty-path checks before submitting lifecycle transactions"],"tags":["chaincode","path","validation","hyperledger-fabric"],"backgroundTag":"empty-chaincode-path","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"}