microsoft/typescript-go · warning

%s: %w

Error message

%s: %w

What it means

checkmodpaths wraps golang.org/x/mod/module.CheckFilePath failures with the offending file's path. CheckFilePath validates that each repository path is a valid, portable Go-module file path (slash-separated, no empty/./.. elements, no Windows-reserved device names, no trailing ~ or leading dots, valid characters).

Source

Thrown at _tools/cmd/checkmodpaths/main.go:45

	var errors []error
	err = fs.WalkDir(os.DirFS(path), ".", func(p string, d fs.DirEntry, err error) error {
		if err != nil {
			return err
		}

		if p == "." {
			return nil
		}

		if p[0] == '.' || p[0] == '_' {
			if d.IsDir() {
				return fs.SkipDir
			}
			return nil
		}

		if err := module.CheckFilePath(p); err != nil {
			errors = append(errors, fmt.Errorf("%s: %w", p, err))
		}

		return nil
	})
	if err != nil {
		fmt.Println("Error walking the directory:", err)
		return 1
	}

	if len(errors) > 0 {
		for _, err := range errors {
			fmt.Println(err)
		}
		return 1
	}

	fmt.Println("All module paths are valid.")
	return 0

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Rename the offending file listed before the colon to a valid module path (no reserved device names, no trailing ~, no ':' etc.)
  2. Remove accidentally committed backup/temp files
  3. git mv the path if case-only or structural fixes are needed, then re-run checkmodpaths <path>

Example fix

# before
repo/aux.c        # 'aux' is a reserved device name
repo/notes.md~    # trailing '~' is invalid

# after
git mv repo/aux.c repo/auxiliary.c
rm repo/notes.md~
checkmodpaths repo
Defensive patterns

Strategy: validation

Validate before calling

import "golang.org/x/mod/module";
if err := module.CheckFilePath(filepath.ToSlash(relPath)); err != nil { /* rename file before committing */ }

Type guard

func validModPath(p string) bool { return module.CheckFilePath(p) == nil }

Try / catch

if err := module.CheckFilePath(p); err != nil { log.Printf("%s: %v — rename or remove this file", p, err); }

Prevention

When it happens

Trigger: Running the checkmodpaths tool over a repo tree containing a file whose path violates module path rules: 'aux.c', 'CON', 'foo~', 'a:b.txt', elements starting with '.' or containing backslashes/illegal code points.

Common situations: CI checks on repos that must be importable as Go modules; files committed from Windows with reserved names; editor backup files ('file.rs~') accidentally committed.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/874710add3ea8637. Report an issue: GitHub.