{"record":{"id":"5c75b672d48e321f","repo":"projectdiscovery/nuclei","slug":"could-not-parse-entities-s","errorCode":null,"errorMessage":"could not parse entities: %s","messagePattern":"could not parse entities: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/devtools/tsgen/cmd/tsgen/main.go","lineNumber":90,"sourceCode":"\t\t\tfor _, file := range files {\n\t\t\t\tif !file.IsDir() && strings.HasSuffix(file.Name(), \".go\") {\n\t\t\t\t\tdirs = append(dirs, path)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\t// walk each directory\n\tfor _, dir := range dirs {\n\t\tentityList := []tsgen.Entity{}\n\t\tep, err := tsgen.NewEntityParser(dir)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Errorf(\"could not create entity parser: %s\", err))\n\t\t}\n\t\tif err := ep.Parse(); err != nil {\n\t\t\tpanic(fmt.Errorf(\"could not parse entities: %s\", err))\n\t\t}\n\t\tentityList = append(entityList, ep.GetEntities()...)\n\t\tentityList = sortEntities(entityList)\n\t\tvar buff bytes.Buffer\n\t\terr = tmpl.Execute(&buff, entityList)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tmoduleName := filepath.Base(dir)\n\t\tgologger.Info().Msgf(\"Writing %s.ts\", moduleName)\n\t\t// create appropriate directory if missing\n\t\t// _ = fileutil.CreateFolder(filepath.Join(out, moduleName))\n\t\t_ = os.WriteFile(filepath.Join(out, moduleName)+\".ts\", buff.Bytes(), 0755)\n\t}\n\n\t// generating index.ts file\n\tvar buff bytes.Buffer\n\tfor _, dir := range dirs {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/devtools/tsgen/cmd/tsgen/main.go#L72-L108","documentation":"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.","triggerScenarios":"Running tsgen while the working tree has Go code under pkg/js/libs that does not compile: syntax errors, unresolved imports, half-applied edits.","commonSituations":"Regenerating bindings mid-refactor; merge conflicts left in lib files; local WIP code that go build would also reject.","solutions":["Run go build ./pkg/js/... first and fix any compile errors it reports","Open the file/line named in the wrapped message and fix the syntax error","Re-run make jsupdate-all once the tree compiles"],"exampleFix":"# before\ngo build ./pkg/js/...   # fails: syntax error in libs/foo/foo.go:42\nmake jsupdate-all        # panics: could not parse entities\n\n# after\n# fix libs/foo/foo.go:42, then\ngo build ./pkg/js/... && make jsupdate-all","handlingStrategy":"validation","validationCode":"# compile gate before running tsgen\ngo build ./pkg/js/... || { echo 'fix compile errors first'; exit 1; }\nmake jsupdate-all","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Never regenerate bindings with a broken working tree","Resolve merge conflicts under pkg/js/libs before codegen","gate codegen on go build in CI"],"tags":["devtools","tsgen","go","code-generation"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}