{"record":{"id":"0cc0624dee2fc902","repo":"anomalyco/sst","slug":"failed-to-find-package-archive-w","errorCode":null,"errorMessage":"failed to find package archive: %w","messagePattern":"failed to find package archive: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":287,"sourceCode":"func extractAndProcessPackageArchive(outputDir string, pkg *localPackageInfo) error {\n\t// Python normalizes package names: dashes become underscores\n\tnormalizedName := strings.ReplaceAll(pkg.Name, \"-\", \"_\")\n\n\t// Try wheel files first\n\tpatterns := []string{\n\t\tfilepath.Join(outputDir, normalizedName+\"-*.whl\"),\n\t\tfilepath.Join(outputDir, normalizedName+\"-*.tar.gz\"),\n\t\tfilepath.Join(outputDir, pkg.Name+\"-*.whl\"),\n\t\tfilepath.Join(outputDir, pkg.Name+\"-*.tar.gz\"),\n\t}\n\n\tvar files []string\n\tvar err error\n\n\tfor _, pattern := range patterns {\n\t\tfiles, err = filepath.Glob(pattern)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to find package archive: %w\", err)\n\t\t}\n\t\tif len(files) > 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif len(files) == 0 {\n\t\treturn fmt.Errorf(\"no package archive found for %s (tried patterns: %s-*.whl, %s-*.tar.gz, %s-*.whl, %s-*.tar.gz)\",\n\t\t\tpkg.Name, normalizedName, normalizedName, pkg.Name, pkg.Name)\n\t}\n\n\t// Process each archive file\n\tfor _, archiveFile := range files {\n\t\tif err := processPackageArchive(archiveFile, outputDir); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to process archive %s: %w\", archiveFile, err)\n\t\t}\n\t}\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L269-L305","documentation":"`extractAndProcessPackageArchive` searches build output with `filepath.Glob` for the downloaded package archive (.whl or .tar.gz). This error wraps an error returned by `filepath.Glob` itself, which only happens when the pattern is malformed (e.g. bad character class or unbalanced brackets), not when no files match.","triggerScenarios":"Calling `buildPackage` for a Python function whose `install` list contains a package name with glob-invalid characters (e.g. `[` or `!`) that end up embedded in the search pattern.","commonSituations":"Hand-edited `sst.config.ts` with a typo in a package name such as `reqs[uests`; package names generated dynamically from user input and injected into the glob pattern.","solutions":["Check the package names in the `install` array for glob metacharacters like `[` or `]` and correct or remove them","Run with debug logging to see the exact pattern that failed","Quote/escape or sanitize package names before they reach the build step"],"exampleFix":"// before\ninstall: [\"reqs[uests\"]\n// after\ninstall: [\"requests\"]","handlingStrategy":"validation","validationCode":"const bad = pkgNames.filter(n => /[[\\]!]/.test(n));\nif (bad.length) throw new Error(`Glob-invalid package names: ${bad.join(\", \")}`);","typeGuard":null,"tryCatchPattern":"try {\n  await buildPackage(...);\n} catch (e) {\n  if (String(e).includes(\"failed to find package archive\")) {\n    console.error(\"Package name contains glob metacharacters:\", e);\n  }\n  throw e;\n}","preventionTips":["Keep package names as plain PyPI names (letters, digits, dots, dashes, underscores)","Never inject user input directly into `install` names","Copy package names from PyPI rather than typing them"],"tags":["python","glob","package-install"],"backgroundTag":"invalid-glob-pattern","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}