{"record":{"id":"334342553c32eb52","repo":"projectdiscovery/nuclei","slug":"encountered-errors-while-performing-template-valid","errorCode":null,"errorMessage":"encountered errors while performing template validation","messagePattern":"encountered errors while performing template validation","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/runner/runner.go","lineNumber":720,"sourceCode":"\t\tos.Exit(0)\n\t}\n\n\tif r.options.TemplateList || r.options.TemplateDisplay {\n\t\tif err := store.LoadTemplatesOnlyMetadata(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tr.listAvailableStoreTemplates(store)\n\t\tos.Exit(0)\n\t}\n\n\tif r.options.Validate {\n\t\tif err := store.ValidateTemplates(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif stats.GetValue(templates.TemplateSyntaxErrorStats) == 0 && stats.GetValue(templates.TemplateSyntaxWarningStats) == 0 && stats.GetValue(templates.TemplateRuntimeWarningStats) == 0 {\n\t\t\tr.Logger.Info().Msgf(\"All templates validated successfully\")\n\t\t} else {\n\t\t\treturn errors.New(\"encountered errors while performing template validation\")\n\t\t}\n\t\treturn nil // exit\n\t}\n\tif err := store.Load(); err != nil {\n\t\treturn err\n\t}\n\t// TODO: remove below functions after v3 or update warning messages\n\ttemplates.PrintDeprecatedProtocolNameMsgIfApplicable(r.options.Silent, r.options.Verbose)\n\n\t// add the hosts from the metadata queries of loaded templates into input provider\n\tif r.options.Uncover && len(r.options.UncoverQuery) == 0 {\n\t\tuncoverOpts := &uncoverlib.Options{\n\t\t\tLimit:         r.options.UncoverLimit,\n\t\t\tMaxRetry:      r.options.Retries,\n\t\t\tTimeout:       r.options.Timeout,\n\t\t\tRateLimit:     uint(r.options.UncoverRateLimit),\n\t\t\tRateLimitUnit: time.Minute, // default unit is minute\n\t\t}","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/internal/runner/runner.go#L702-L738","documentation":"Twin cleanup guard in the same defer: the code panics when os.Remove of the temp file fails. On Windows this is classically antivirus/EDR still holding the file open; elsewhere it is a vanished file or lost permissions on the temp directory. It panics by design so cleanup failures are never swallowed.","triggerScenarios":"Windows AV scanning nuclei's temp copy at the instant of removal; a shared TMPDIR where another process deletes files; permission changes on the temp dir mid-scan.","commonSituations":"EDR-equipped Windows hosts; parallel runs sharing one TMPDIR; hardening policies that lock temp files.","solutions":["Add an antivirus exclusion for the TMPDIR nuclei uses (and the nuclei binary)","Give each run a private TMPDIR with permissive cleanup","Re-run the single failing file to confirm the cause; report persistent cases upstream"],"exampleFix":"# before: shared temp dir policed by AV\n# after\nmkdir -p /var/tmp/nuclei-run && TMPDIR=/var/tmp/nuclei-run nuclei -t file.yaml -l files.txt","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        // temp-file removal panic (often AV lock on Windows): log and continue\n        log.Printf(\"file protocol cleanup panic: %v\", r)\n    }\n}()\nerr := engine.ExecuteWithResults(target, ...)\nif err != nil {\n    log.Printf(\"execute failed: %v\", err)\n}","preventionTips":["Add an AV/EDR exclusion for the nuclei TMPDIR","Use a private temp dir per run","Retry the single failing file after exclusions are in place"],"tags":["file","temp-file","panic","windows","antivirus"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}