pulumi/pulumi · error

source positions must include absolute paths

Error message

source positions must include absolute paths

What it means

After confirming the file scheme, the engine converts the position path to an OS path and requires it to be absolute so it can be made relative to the project root. A relative path would make the resulting project:// URI ambiguous, so the engine rejects it.

Source

Thrown at pkg/resource/deploy/source_eval.go:2088

	col := ""
	if raw.Column != 0 {
		if raw.Column < 0 {
			return "", fmt.Errorf("invalid column number %v", raw.Column)
		}
		col = "," + strconv.FormatInt(int64(raw.Column), 10)
	}

	posURL, err := url.Parse(raw.Uri)
	if err != nil {
		return "", err
	}
	if posURL.Scheme != "file" {
		return "", fmt.Errorf("unrecognized scheme %q", posURL.Scheme)
	}

	file := filepath.FromSlash(posURL.Path)
	if !filepath.IsAbs(file) {
		return "", errors.New("source positions must include absolute paths")
	}
	rel, err := filepath.Rel(s.projectRoot, file)
	if err != nil {
		return "", fmt.Errorf("making relative path: %w", err)
	}

	posURL.Scheme = "project"
	posURL.Path = "/" + filepath.ToSlash(rel)
	posURL.Fragment = fmt.Sprintf("%v%s", raw.Line, col)

	return posURL.String(), nil
}

func (s *sourcePositions) newStackTrace(raw *pulumirpc.StackTrace) stackTrace {
	if raw == nil {
		return nil
	}

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Ensure the language host/program reports absolute source file paths
  2. Run the program from a correct working directory so tools resolve absolute paths
  3. Check the position-producing tool/SDK version for relative-path bugs and upgrade

Example fix

// before
"file://src/index.ts#5"
// after
"file:///home/user/project/src/index.ts#5"
Defensive patterns

Strategy: validation

Validate before calling

p := filepath.FromSlash(u.Path)
if !filepath.IsAbs(p) {
    p, _ = filepath.Abs(p)
    u.Path = filepath.ToSlash(p)
}

Type guard

func isAbsPosition(u *url.URL) bool { return filepath.IsAbs(filepath.FromSlash(u.Path)) }

Prevention

When it happens

Trigger: A source position URI like file://main.ts or file://../lib/x.ts (relative path component) reaches the position translation in source_eval.go.

Common situations: Language host emits positions relative to the working directory instead of absolute; symlinked or sandboxed execution where paths are computed relative; custom providers emitting compact positions.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/18fdff932aca4e24. Report an issue: GitHub.