{"record":{"id":"f1ed7878ca1a8d4e","repo":"projectdiscovery/nuclei","slug":"could-not-create-entity-parser-s","errorCode":null,"errorMessage":"could not create entity parser: %s","messagePattern":"could not create entity parser: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/devtools/tsgen/cmd/tsgen/main.go","lineNumber":87,"sourceCode":"\t\t// only load module directory skip root directory\n\t\tif d.IsDir() {\n\t\t\tfiles, _ := os.ReadDir(path)\n\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","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/devtools/tsgen/cmd/tsgen/main.go#L69-L105","documentation":"The tsgen codegen tool could not construct its entity parser for a walked directory (tsgen.NewEntityParser(dir) failed) and — being a codegen CLI — panics immediately. Root causes: directory missing/unreadable, or parser setup failing on the directory's Go files.","triggerScenarios":"Running tsgen where a collected dir does not exist, lacks read permission, or has no parseable Go files, so NewEntityParser returns an error.","commonSituations":"Running tsgen from outside the repo root so relative dirs resolve wrongly; a moved/renamed lib dir; permission-restricted checkouts (CI sandboxes).","solutions":["Run from the repository root via the make targets (make jsupdate-all / devtools-all) so directory walking matches expectations","Verify each walked dir exists and is readable: ls pkg/js/libs/<module>","Read the wrapped %s message — it names the underlying parser failure"],"exampleFix":"# before\ntsgen ../nuclei/pkg/js/libs   # wrong cwd\n\n# after\ncd /path/to/nuclei && make jsupdate-all","handlingStrategy":"validation","validationCode":"for _, dir := range dirs {\n    info, err := os.Stat(dir)\n    if err != nil || !info.IsDir() {\n        log.Fatalf(\"cannot walk %s: %v\", dir, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"The tool panics by design; run tsgen via the make targets and fix whatever the wrapped %s names (missing dir, permissions) before re-running.","preventionTips":["Always run tsgen from the repo root (or via make jsupdate-all)","Verify lib directories exist after renames","Ensure read access in sandboxed CI checkouts"],"tags":["devtools","tsgen","typescript","code-generation"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}