{"record":{"id":"05208c53524760c2","repo":"anomalyco/sst","slug":"failed-to-copy-lambda-bridge-v","errorCode":null,"errorMessage":"failed to copy lambda bridge: %v","messagePattern":"failed to copy lambda bridge: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/python.go","lineNumber":151,"sourceCode":"\nfunc (r *PythonRuntime) Run(ctx context.Context, input *runtime.RunInput) (runtime.Worker, error) {\n\tisLegacyLayout, err := r.syncArtifactsIfNeeded(input)\n\tif err != nil {\n\t\tslog.Error(\"failed to sync artifacts\",\n\t\t\t\"functionID\", input.FunctionID,\n\t\t\t\"error\", err)\n\t\treturn nil, fmt.Errorf(\"failed to sync artifacts: %v\", err)\n\t}\n\n\t// Copy lambda bridge to artifact directory if missing or outdated\n\tlambdaBridgePath := filepath.Join(input.Build.Out, \"lambdaric_python_bridge.py\")\n\tsourceBridgePath := filepath.Join(path.ResolvePlatformDir(input.CfgPath), \"/dist/python-runtime/index.py\")\n\n\tdstInfo, dstErr := os.Stat(lambdaBridgePath)\n\tsrcInfo, srcErr := os.Stat(sourceBridgePath)\n\tif dstErr != nil || (srcErr == nil && srcInfo.ModTime().After(dstInfo.ModTime())) {\n\t\tif err := copyFile(sourceBridgePath, lambdaBridgePath); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to copy lambda bridge: %v\", err)\n\t\t}\n\t}\n\n\tprojectRoot := path.ResolveRootDir(input.CfgPath)\n\n\tvar handlerPath string\n\tvar workingDir string\n\n\tif isLegacyLayout {\n\t\t// Use relative handler since workingDir is the artifact directory\n\t\thandlerPath = r.adjustHandlerForFlattenedLayout(input.Build.Handler)\n\t\tworkingDir = input.Build.Out\n\t} else {\n\t\t// Modern layout: run from source with PYTHONPATH\n\t\thandlerPath = input.Build.Handler\n\t\tworkingDir = projectRoot\n\t}\n","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/python.go#L133-L169","documentation":"During PythonRuntime.Run, after syncing artifacts, the runtime copies the lambdaric_python_bridge.py from the platform dist (dist/python-runtime/index.py) into the build output when it's missing or older than the source. Failure of copyFile is wrapped as \"failed to copy lambda bridge: %v\". Without the bridge file, the worker would lack its entrypoint, so this is fatal.","triggerScenarios":"os.Stat found the destination bridge missing/stale and copyFile failed: source bridge absent (platform not built — platform/dist/python-runtime/index.py missing), destination directory not writable, or disk full.","commonSituations":"Fresh clone without running `bun run setup`/platform build, so ResolvePlatformDir(...)/dist/python-runtime/index.py doesn't exist; deploying in a container with a read-only platform dir; permissions broken on .sst output after running commands as root vs user.","solutions":["Build the platform first (`bun run build:platform` or `bun run setup`) so dist/python-runtime/index.py exists.","Check the wrapped %v error: if 'no such file', the platform dist is missing; if 'permission denied', fix output dir permissions.","Verify the build output directory (input.Build.Out) is writable by the current user.","Clear the stale artifact dir and rebuild to force a fresh bridge copy."],"exampleFix":"// before: fresh clone, platform not built\n// failed to copy lambda bridge: ... no such file\n\n// after\n$ bun run setup && sst dev","handlingStrategy":"validation","validationCode":"// shell, before dev/deploy\ntest -f <platform-dir>/dist/python-runtime/index.py && echo OK || echo 'platform not built: run bun run build:platform'","typeGuard":null,"tryCatchPattern":"try { await deploy() } catch (e) {\n  if (String(e).includes(\"failed to copy lambda bridge\")) {\n    await buildPlatform(); // regenerate dist/python-runtime/index.py\n    await deploy();\n  }\n  throw e;\n}","preventionTips":["Run `bun run setup` / `bun run build:platform` after cloning or upgrading.","Ensure .sst output and platform dist dirs are writable by the deploy user.","Avoid running deploys as root in containers sharing volumes with your user."],"tags":["python","runtime","lambda-bridge","file-copy"],"backgroundTag":"artifact-sync-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}