projectdiscovery/nuclei · error

could not parse entities: %s

Error message

could not parse entities: %s

What it means

tsgen's entity parser failed to Parse() the Go source of a libs directory — the Go parser/type-checker rejected files inside pkg/js/libs/<module>. The wrapped %s carries the actual syntax or type error with file/line.

Source

Thrown at pkg/js/devtools/tsgen/cmd/tsgen/main.go:90

			for _, file := range files {
				if !file.IsDir() && strings.HasSuffix(file.Name(), ".go") {
					dirs = append(dirs, path)
					break
				}
			}
		}
		return nil
	})

	// walk each directory
	for _, dir := range dirs {
		entityList := []tsgen.Entity{}
		ep, err := tsgen.NewEntityParser(dir)
		if err != nil {
			panic(fmt.Errorf("could not create entity parser: %s", err))
		}
		if err := ep.Parse(); err != nil {
			panic(fmt.Errorf("could not parse entities: %s", err))
		}
		entityList = append(entityList, ep.GetEntities()...)
		entityList = sortEntities(entityList)
		var buff bytes.Buffer
		err = tmpl.Execute(&buff, entityList)
		if err != nil {
			panic(err)
		}
		moduleName := filepath.Base(dir)
		gologger.Info().Msgf("Writing %s.ts", moduleName)
		// create appropriate directory if missing
		// _ = fileutil.CreateFolder(filepath.Join(out, moduleName))
		_ = os.WriteFile(filepath.Join(out, moduleName)+".ts", buff.Bytes(), 0755)
	}

	// generating index.ts file
	var buff bytes.Buffer
	for _, dir := range dirs {

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Run go build ./pkg/js/... first and fix any compile errors it reports
  2. Open the file/line named in the wrapped message and fix the syntax error
  3. Re-run make jsupdate-all once the tree compiles

Example fix

# before
go build ./pkg/js/...   # fails: syntax error in libs/foo/foo.go:42
make jsupdate-all        # panics: could not parse entities

# after
# fix libs/foo/foo.go:42, then
go build ./pkg/js/... && make jsupdate-all
Defensive patterns

Strategy: validation

Validate before calling

# compile gate before running tsgen
go build ./pkg/js/... || { echo 'fix compile errors first'; exit 1; }
make jsupdate-all

Try / catch

Parse the wrapped %s for file:line, fix the Go syntax error there, and re-run; there is no way to skip a failing directory in the shipped tool.

Prevention

When it happens

Trigger: Running tsgen while the working tree has Go code under pkg/js/libs that does not compile: syntax errors, unresolved imports, half-applied edits.

Common situations: Regenerating bindings mid-refactor; merge conflicts left in lib files; local WIP code that go build would also reject.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/5c75b672d48e321f. Report an issue: GitHub.