{"record":{"id":"a20efd45ba4d07b8","repo":"anomalyco/sst","slug":"failed-to-read-pyproject-toml-for-workspace-packag","errorCode":null,"errorMessage":"failed to read pyproject.toml for workspace package %s: %w","messagePattern":"failed to read pyproject\\.toml for workspace package (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":704,"sourceCode":"\n\t\t// Resolve full path relative to workspace root\n\t\tfullPath := filepath.Join(workspaceRoot, pkgPath)\n\t\tif _, err := os.Stat(fullPath); err != nil {\n\t\t\tslog.Warn(\"workspace package directory not found\", \"path\", fullPath, \"line\", line)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Copy to artifact at the same relative path\n\t\tdestPath := filepath.Join(input.Out(), pkgPath)\n\t\tif _, err := os.Stat(destPath); err == nil {\n\t\t\t// Already exists — just ensure pyproject.toml is present for uv pip install\n\t\t\tsrcPyproject := filepath.Join(fullPath, \"pyproject.toml\")\n\t\t\tdestPyproject := filepath.Join(destPath, \"pyproject.toml\")\n\t\t\tif _, err := os.Stat(srcPyproject); err == nil {\n\t\t\t\tif _, err := os.Stat(destPyproject); err != nil {\n\t\t\t\t\tdata, readErr := os.ReadFile(srcPyproject)\n\t\t\t\t\tif readErr != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to read pyproject.toml for workspace package %s: %w\", pkgPath, readErr)\n\t\t\t\t\t}\n\t\t\t\t\tif err := os.WriteFile(destPyproject, data, 0644); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"failed to copy pyproject.toml for workspace package %s: %w\", pkgPath, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create directory for workspace package %s: %w\", pkgPath, err)\n\t\t}\n\n\t\t// Preserve pyproject.toml and metadata for uv pip install\n\t\tif err := copyDir(fullPath, destPath, skipBuildArtifacts); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy workspace package %s: %w\", pkgPath, err)\n\t\t}\n","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L686-L722","documentation":"copyWorkspacePackagesForContainer ensures each workspace package's pyproject.toml exists at the destination so the container build can install the package. When the destination lacks the file, it reads the source pyproject.toml; a read failure there is wrapped with the package path. Later steps need this file, so the container build cannot proceed without it.","triggerScenarios":"os.ReadFile(srcPyproject) fails even though os.Stat earlier saw it: file removed between stat and read (race/concurrent build), permissions changed, or the path is a directory/broken symlink.","commonSituations":"Two concurrent builds racing over the same workspace (one deletes the temp/package dir mid-copy); pyproject.toml replaced by a directory or symlink pointing nowhere; a package directory created without read permissions in CI.","solutions":["Re-run the build without concurrent jobs touching the same output/workspace (serialize builds)","Verify the pyproject.toml in the package path is a regular readable file (file path/to/pyproject.toml, ls -la)","Restore the missing/broken pyproject.toml in the workspace package (git checkout -- packages/<pkg>/pyproject.toml)","Fix permissions: chmod u+r on the file and u+rx on the package directory"],"exampleFix":"// before\n// packages/shared exists but pyproject.toml is a dangling symlink\n$ rm packages/shared/pyproject.toml\n// after\ncat > packages/shared/pyproject.toml <<'EOF'\n[project]\nname = \"shared\"\nversion = \"0.1.0\"\nEOF","handlingStrategy":"validation","validationCode":"for _, pkg := range workspacePackages {\n\tpp := filepath.Join(pkg.Path, \"pyproject.toml\")\n\tfi, err := os.Lstat(pp)\n\tif err != nil {\n\t\tlog.Fatalf(\"%s missing in package %s\", pp, pkg.Name)\n\t}\n\tif !fi.Mode().IsRegular() {\n\t\tlog.Fatalf(\"%s is not a regular file (symlink/dir) in %s\", pp, pkg.Name)\n\t}\n\tif _, err := os.ReadFile(pp); err != nil {\n\t\tlog.Fatalf(\"%s unreadable: %v\", pp, err)\n\t}\n}","typeGuard":"func hasReadablePyproject(pkgPath string) bool {\n\tpp := filepath.Join(pkgPath, \"pyproject.toml\")\n\tfi, err := os.Stat(pp)\n\tif err != nil || !fi.Mode().IsRegular() {\n\t\treturn false\n\t}\n\t_, err = os.ReadFile(pp)\n\treturn err == nil\n}","tryCatchPattern":"if err := deploy(); err != nil && strings.Contains(err.Error(), \"failed to read pyproject.toml\") {\n\tfmt.Println(\"restore the package's pyproject.toml and avoid concurrent builds over the same workspace\")\n\tos.Exit(1)\n}","preventionTips":["Commit pyproject.toml for every workspace Python package","Don't run concurrent builds targeting the same output/workspace (stat-then-read race)","Keep packages as regular files, not dangling symlinks, in CI checkouts","chmod u+r package files after extracting archives in CI"],"tags":["filesystem","python","container","pyproject-toml","workspace"],"backgroundTag":"file-read-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}