{"record":{"id":"253df1b2ef2f5c24","repo":"hyperledger/fabric","slug":"no-source-files-found-in-s","errorCode":null,"errorMessage":"no source files found in '%s'","messagePattern":"no source files found in '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/util/writer.go","lineNumber":101,"sourceCode":"\t\t\tpackagepath = path.Join(\"src\", packagepath)\n\t\t}\n\n\t\terr = WriteFileToPackage(localpath, packagepath, tw)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error writing file to package: %s\", err)\n\t\t}\n\n\t\tsuccess = true\n\t\treturn nil\n\t}\n\n\tif err := filepath.Walk(rootDirectory, walkFn); err != nil {\n\t\tlogger.Infof(\"Error walking rootDirectory: %s\", err)\n\t\treturn err\n\t}\n\n\tif !success {\n\t\treturn errors.Errorf(\"no source files found in '%s'\", srcPath)\n\t}\n\treturn nil\n}\n\n// WriteFileToPackage writes a file to a tar stream.\nfunc WriteFileToPackage(localpath string, packagepath string, tw *tar.Writer) error {\n\tlogger.Debug(\"Writing file to tarball:\", packagepath)\n\tfd, err := os.Open(localpath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %s\", localpath, err)\n\t}\n\tdefer fd.Close()\n\n\tfi, err := fd.Stat()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %s\", localpath, err)\n\t}\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/util/writer.go#L83-L119","documentation":"Thrown by WriteFolderToTarPackage when filepath.Walk completed without any file being added to the tar package (the `success` flag was never set). This means the source directory contained no files matching the include/exclude filters, so the resulting package would be empty.","triggerScenarios":"srcPath points to an empty directory; every file's extension is excluded by excludeFileTypeMap or not in includeFileTypeMap (e.g. passing a non-nil includeFileTypeMap that matches no extensions); all files reside only in excluded directories (.git plus excludeDirs); the directory contains only hidden or metadata files that get skipped.","commonSituations":"Pointing the packager at the wrong path (parent directory instead of the chaincode folder); building a Node.js chaincode whose source is in a subfolder; overly restrictive includeFileTypeMap; chaincode repo where all code lives inside an excluded dir.","solutions":["Verify srcPath points to the directory that actually contains chaincode source files","Check includeFileTypeMap/excludeFileTypeMap filters do not exclude every file extension","Ensure source files are not located inside directories listed in excludeDirs","List the directory contents (ls -laR) to confirm there are matching files"],"exampleFix":"// before: wrong path / overly strict filter\nerr := util.WriteFolderToTarPackage(tw, \"/empty-or-wrong-dir\", nil, map[string]bool{\".go\": true}, nil)\n// after: correct path with appropriate filters\nerr := util.WriteFolderToTarPackage(tw, \"/path/to/chaincode\", []string{\".git\"}, nil, nil)","handlingStrategy":"validation","validationCode":"// verify the source folder contains at least one candidate file before packaging\nhasFile := false\nfilepath.Walk(srcPath, func(p string, info os.FileInfo, err error) error {\n    if err == nil && !info.IsDir() && !strings.HasPrefix(info.Name(), \".\") {\n        hasFile = true\n    }\n    return nil\n})\nif !hasFile {\n    return fmt.Errorf(\"%s contains no files to package\", srcPath)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always confirm srcPath points at the directory directly containing chaincode sources","Keep include/exclude extension maps permissive enough to match your source files","Do not place all sources inside excluded directories","Run ls on the path (or a CI check) before packaging"],"tags":["packaging","empty-input","path","tar"],"backgroundTag":"no-source-files-found","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"}