{"record":{"id":"21dcb79fe2d17b64","repo":"anomalyco/sst","slug":"failed-to-copy-source-files-w","errorCode":null,"errorMessage":"failed to copy source files: %w","messagePattern":"failed to copy source files: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":639,"sourceCode":"\n// inputProperties represents the input properties structure\ntype inputProperties struct {\n\tArchitecture string `json:\"architecture\"`\n}\n\n// parseInputProperties parses the input properties JSON\nfunc parseInputProperties(input *runtime.BuildInput) (*inputProperties, error) {\n\tvar props inputProperties\n\tif err := json.Unmarshal(input.Properties, &props); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse properties: %w\", err)\n\t}\n\n\treturn &props, nil\n}\n\nfunc installDependenciesForLambda(ctx context.Context, input *runtime.BuildInput, projectInfo *projectInfo, architecture string) error {\n\tif err := copySourceFilesSimple(input, projectInfo); err != nil {\n\t\treturn fmt.Errorf(\"failed to copy source files: %w\", err)\n\t}\n\n\t// Container builds: Dockerfile handles deps; zip builds: install here\n\tif input.IsContainer {\n\t\tif err := copyWorkspacePackagesForContainer(input, projectInfo); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy workspace packages for container: %w\", err)\n\t\t}\n\t} else {\n\t\tif err := copySyncedDependencies(ctx, input, projectInfo, architecture); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy synced dependencies: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// copyWorkspacePackagesForContainer copies workspace package directories into the artifact\n// so the Dockerfile's `uv pip install -r requirements.txt` can resolve relative paths.","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L621-L657","documentation":"installDependenciesForLambda first copies the function's source files into the build output via copySourceFilesSimple. If that copy step fails, nothing else proceeds and the error is wrapped here. It indicates the source tree could not be read or the destination could not be written.","triggerScenarios":"copySourceFilesSimple fails: the configured source directory doesn't exist or has a wrong srcPath in the sst config, unreadable source files (permissions), or unwritable/full build output.","commonSituations":"Typo'd or moved path in the sst config (function's srcPath points to a deleted/renamed folder); .gitignore-style excludes hiding everything; running the build in a container/CI that mounted the repo at a different path; restrictive file modes from an extracted archive.","solutions":["Verify the srcPath in your sst config exists relative to the project root and contains your Python entry files","Fix read permissions on source files and write permissions on the build output (chmod -R u+rw)","Run from the project root (or set the correct root) so relative paths resolve","Check the wrapped inner error for the exact file that failed and correct/remove it"],"exampleFix":"// before (sst.config.ts)\nnew sst.aws.PythonFunction(\"Fn\", { srcPath: \"services/api-py\" })\n// error: failed to copy source files (dir renamed)\n// after\nls services/api-python  # actual dir\nnew sst.aws.PythonFunction(\"Fn\", { srcPath: \"services/api-python\" })","handlingStrategy":"validation","validationCode":"srcPath := \"services/api-python\" // from sst.config.ts\nif fi, err := os.Stat(srcPath); err != nil || !fi.IsDir() {\n\tlog.Fatalf(\"srcPath %q does not exist — fix sst.config.ts\", srcPath)\n}\nif _, err := os.Stat(filepath.Join(srcPath, \"<handler>.py\")); err != nil {\n\tlog.Fatalf(\"handler file missing in %s\", srcPath)\n}","typeGuard":null,"tryCatchPattern":"if err := deploy(); err != nil && strings.Contains(err.Error(), \"failed to copy source files\") {\n\tfmt.Println(\"check srcPath in sst.config.ts exists and contains your .py files; check file permissions\")\n\tos.Exit(1)\n}","preventionTips":["Keep srcPath in sync with actual directory names (update config on renames)","Run sst commands from the project root so relative paths resolve","Ensure source files are readable by the build user in CI containers","Don't gitignore/delete files the function depends on"],"tags":["filesystem","io","python","build","source-files"],"backgroundTag":"file-copy-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}