{"record":{"id":"786dd8d1fe462344","repo":"anomalyco/sst","slug":"failed-to-open-source-file-w","errorCode":null,"errorMessage":"failed to open source file: %w","messagePattern":"failed to open source file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/python.go","lineNumber":400,"sourceCode":"\tresult, err := buildDeploy(ctx, input, filepath.Join(workingDir, \".sst/cache/deploy\"), workingDir)\n\tif err != nil {\n\t\tslog.Error(\"build failed\", \"functionID\", input.FunctionID, \"error\", err)\n\t\treturn nil, err\n\t}\n\n\tslog.Info(\"function built\", \"functionID\", input.FunctionID)\n\treturn result, nil\n}\n\n// copyFile copies a single file from src to dst, creating parent directories as needed.\nfunc copyFile(src, dst string) error {\n\tif err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create directory for %s: %w\", dst, err)\n\t}\n\n\tsrcFile, err := os.Open(src)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open source file: %w\", err)\n\t}\n\tdefer srcFile.Close()\n\n\tdstFile, err := os.Create(dst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create destination file: %w\", err)\n\t}\n\tdefer dstFile.Close()\n\n\tif _, err := io.Copy(dstFile, srcFile); err != nil {\n\t\treturn fmt.Errorf(\"failed to copy file contents: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// skipContent skips __pycache__, .pyc files, and anything matching isIgnored.\nfunc skipContent(relPath string, info os.FileInfo) bool {","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/python.go#L382-L418","documentation":"Raised in copyFile (pkg/runtime/python/python.go:400) when os.Open cannot read the source file being copied (bridge script, source .py, or dependency package file). Nearly always 'no such file or directory' because the file was deleted/renamed between the scan and copy, or 'permission denied' when the file is unreadable by the sst process.","triggerScenarios":"Source .py deleted by editor/git right after the walk collected it; dependency package file removed by a concurrent uv install; platform dist/python-runtime/index.py missing when copying the lambda bridge; unreadable file modes from a foreign checkout.","commonSituations":"Rapid save/delete during `sst dev` in workspace-layout projects; incomplete dependency install leaving missing files; platform dir not synced (missing dist/python-runtime/index.py) when Run copies the bridge.","solutions":["Check the wrapped cause: if the named source file is gone, restore it (git checkout/re-save) or restart the sync so the file list is refreshed","If permission denied, chmod/chown the source file so the sst process can read it","If the missing file is the platform bridge, re-sync the platform (rebuild platform dist) so dist/python-runtime/index.py exists"],"exampleFix":"// before\nfailed to open source file: open api/src/api/mod.py: no such file or directory\n// after\ngit checkout -- api/src/api/mod.py\nsst dev","handlingStrategy":"try-catch","validationCode":"// check source readable before copy\nf, err := os.Open(src)\nif err != nil { return fmt.Errorf(\"precheck failed for %s: %v\", src, err) }\nf.Close()","typeGuard":null,"tryCatchPattern":"if err := copyFile(src, dst); err != nil {\n    if errors.Is(err, fs.ErrNotExist) {\n        restoreSource(src) // git checkout / resync, then retry\n        return copyFile(src, dst)\n    }\n    if errors.Is(err, fs.ErrPermission) {\n        return chmodAndRetry(src, dst)\n    }\n    return err\n}","preventionTips":["Restore deleted files (git checkout) instead of leaving the tree inconsistent during dev","Ensure platform is synced so dist/python-runtime/index.py exists before Run","Complete dependency installs before artifact copying; avoid parallel uv installs racing","chmod source files readable (0644) when sharing checkouts across users"],"tags":["filesystem","open","permissions","race","copy","python"],"backgroundTag":"source-file-not-found","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}