{"record":{"id":"2264a89e348ac991","repo":"anomalyco/sst","slug":"failed-to-filter-requirements-w","errorCode":null,"errorMessage":"failed to filter requirements: %w","messagePattern":"failed to filter requirements: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":810,"sourceCode":"\treturn nil\n}\n\n// copySyncedDependencies installs dependencies with correct platform targeting\nfunc copySyncedDependencies(ctx context.Context, input *runtime.BuildInput, projectInfo *projectInfo, architecture string) error {\n\trequirementsPath := filepath.Join(input.Out(), \"requirements.txt\")\n\n\tif _, err := os.Stat(requirementsPath); os.IsNotExist(err) {\n\t\tslog.Warn(\"requirements.txt not found, skipping dependency installation\", \"path\", requirementsPath)\n\t\treturn nil\n\t}\n\n\tworkspaceRoot := findWorkspaceRoot(projectInfo)\n\n\t// Filter editable installs from requirements\n\tfilteredRequirementsPath := filepath.Join(input.Out(), \"requirements-filtered.txt\")\n\terr := filterEditableInstalls(requirementsPath, filteredRequirementsPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to filter requirements: %w\", err)\n\t}\n\trequirementsPath = filteredRequirementsPath\n\n\t// Cache key from requirements hash + architecture\n\trequirementsHash, err := hashFileContents(requirementsPath)\n\tvar cacheKey string\n\tvar depsCacheDir string\n\n\tif err == nil {\n\t\tcacheKey = fmt.Sprintf(\"%s-%s\", requirementsHash, architecture)\n\t\tdepsCacheDir = filepath.Join(filepath.Dir(input.Out()), \".deps\", cacheKey)\n\n\t\t// Acquire lock to prevent concurrent installs for the same cache key\n\t\tglobalDependencyInstallLocksMutex.Lock()\n\t\tcacheLock, exists := globalDependencyInstallLocks[cacheKey]\n\t\tif !exists {\n\t\t\tcacheLock = &sync.Mutex{}\n\t\t\tglobalDependencyInstallLocks[cacheKey] = cacheLock","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L792-L828","documentation":"Before installing Python dependencies for a zip build, SST rewrites requirements.txt into requirements-filtered.txt by stripping editable installs (-e / workspace paths) via filterEditableInstalls. This error is returned when that filtering step fails, wrapping the underlying read/write/parse error.","triggerScenarios":"filterEditableInstalls(requirementsPath, filteredRequirementsPath) fails when requirements.txt in input.Out() is unreadable, the output directory is unwritable, or the requirements file contains lines the filter cannot process (e.g. malformed UTF-8 or a very unusual editable syntax).","commonSituations":"requirements.txt hand-edited with non-UTF8 characters or exotic `-e` lines; previous interrupted build left a directory named requirements-filtered.txt in the output; read-only .sst output.","solutions":["Read the wrapped error; if it concerns requirements-filtered.txt existing as a directory, `rm -rf .sst` and redeploy.","Validate requirements.txt is plain UTF-8 and uses standard syntax; simplify exotic editable lines (`-e ./pkg`).","Let `uv export` regenerate requirements.txt rather than hand-editing it.","Ensure the build output directory is writable by the deploying user."],"exampleFix":"// before\n# requirements.txt (hand edited, invalid)\n-e file:///weird/path\\xff\n// after\n$ rm -rf .sst\n$ sst deploy  # let uv export regenerate requirements.txt","handlingStrategy":"validation","validationCode":"const req = fs.readFileSync(path.join(buildOut, 'requirements.txt'), 'utf8');\nif (!req.isWellFormed?.() && Buffer.from(req).includes(0xFF)) throw new Error('requirements.txt is not valid UTF-8; regenerate with uv export');","typeGuard":"null","tryCatchPattern":"try {\n  await deploy();\n} catch (e) {\n  if (/failed to filter requirements/.test(e.message)) {\n    fs.rmSync('.sst', { recursive: true, force: true }); // clears stale requirements-filtered.txt\n    await deploy();\n  } else throw e;\n}","preventionTips":["Never hand-edit requirements.txt; let uv export generate it","Save requirements files as UTF-8 without exotic control characters","Clean .sst after an interrupted build","Keep standard editable syntax only (-e ./pkg) in project dependencies"],"tags":["python","dependencies","requirements","build"],"backgroundTag":"requirements-parse-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}