anomalyco/sst · error

failed to get absolute path for %s: %w

Error message

failed to get absolute path for %s: %w

What it means

findPythonFile found a matching candidate .py file via os.Stat, but converting the relative candidate path to an absolute path with filepath.Abs failed. This is a rare wrapper around OS-level path resolution errors (e.g. permission issues on a path component or an excessively long path). The %w preserves the original os error.

Source

Thrown at pkg/runtime/python/project.go:91

		ProjectRoot:   projectRoot,
		PyprojectPath: pyprojectPath,
	}

	info.SourceRoot = resolveSourceRoot(projectRoot, pyprojectPath)

	return info, nil
}

// findPythonFile locates the Python file for the given handler path.
func findPythonFile(projectRoot, handlerPath string) (string, error) {
	filePath := extractFilePath(handlerPath)
	candidates := generateCandidatePaths(projectRoot, filePath)

	for _, candidate := range candidates {
		if info, err := os.Stat(candidate); err == nil && info.Mode().IsRegular() && strings.HasSuffix(candidate, ".py") {
			absPath, err := filepath.Abs(candidate)
			if err != nil {
				return "", fmt.Errorf("failed to get absolute path for %s: %w", candidate, err)
			}
			return absPath, nil
		}
	}

	return "", fmt.Errorf("handler not found: %s (searched %d candidate paths)", handlerPath, len(candidates))
}

// extractFilePath extracts the file path from a handler path.
func extractFilePath(handlerPath string) string {
	if lastDot := strings.LastIndex(handlerPath, "."); lastDot != -1 {
		return handlerPath[:lastDot]
	}
	return handlerPath
}

// generateCandidatePaths creates a list of potential file locations.
func generateCandidatePaths(projectRoot, handlerPath string) []string {

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Check filesystem permissions and that the current working directory exists and is accessible.
  2. Inspect the wrapped %w error for the exact OS reason and fix the underlying path/mount issue.
  3. Shorten or normalize the project path if it is near the OS path-length limit.
  4. Re-run from a normal, existing directory (e.g. the repo root).

Example fix

// before (deleted cwd)
$ rm -rf old-dir && sst deploy  # failed to get absolute path ...

// after
$ cd /path/to/project && sst deploy
Defensive patterns

Strategy: try-catch

Try / catch

try { await deploy() } catch (e) {
  if (String(e).includes("failed to get absolute path for"))
    console.error("Check cwd/mount/permissions:", String(e));
  throw e;
}

Prevention

When it happens

Trigger: os.Stat succeeded for a candidate like <root>/src/handler.py but filepath.Abs returned an error — practically only when the process working directory is unreadable, or on filesystems with pathological path lengths/permissions.

Common situations: Running the CLI from a deleted or permission-restricted working directory; deploying inside a container with a broken mount point for the project root; extremely deep monorepo paths exceeding OS path limits.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/3a12300c5505d568. Report an issue: GitHub.