{"record":{"id":"9d3806ffb9d62a13","repo":"projectdiscovery/nuclei","slug":"failed-to-load-templates-w","errorCode":null,"errorMessage":"failed to load templates: %w","messagePattern":"failed to load templates: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/runner/lazy.go","lineNumber":72,"sourceCode":"\topts.ExcludeIds = nil\n\topts.Protocols = nil\n\topts.ExcludeProtocols = nil\n\topts.IncludeConditions = nil\n\tcfg := loader.NewConfig(opts, catalog, execOpts)\n\tcfg.StoreId = loader.AuthStoreId\n\tstore, err := loader.New(cfg)\n\tif err != nil {\n\t\treturn nil, errkit.Wrap(err, \"failed to initialize dynamic auth templates store\")\n\t}\n\treturn store, nil\n}\n\n// GetLazyAuthFetchCallback returns a lazy fetch callback for auth secrets\nfunc GetLazyAuthFetchCallback(opts *AuthLazyFetchOptions) authx.LazyFetchSecret {\n\treturn func(d *authx.Dynamic) error {\n\t\ttmpls, err := opts.TemplateStore.LoadTemplates([]string{d.TemplatePath})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to load templates: %w\", err)\n\t\t}\n\t\tif len(tmpls) == 0 {\n\t\t\treturn fmt.Errorf(\"%w for path: %s\", disk.ErrNoTemplatesFound, d.TemplatePath)\n\t\t}\n\t\tif len(tmpls) > 1 {\n\t\t\treturn fmt.Errorf(\"multiple templates found for path: %s\", d.TemplatePath)\n\t\t}\n\t\tdata := map[string]interface{}{}\n\t\ttmpl := tmpls[0]\n\t\t// add args to tmpl here\n\t\tvars := map[string]interface{}{}\n\t\tmainCtx := context.Background()\n\t\tctx := scan.NewScanContext(mainCtx, contextargs.NewWithInput(mainCtx, d.Input))\n\n\t\tcliVars := map[string]interface{}{}\n\t\tif opts.ExecOpts.Options != nil {\n\t\t\t// gets variables passed from cli -v and -env-vars\n\t\t\tcliVars = generators.BuildPayloadFromOptions(opts.ExecOpts.Options)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/internal/runner/lazy.go#L54-L90","documentation":"Inside the lazy dynamic-secrets callback (internal/runner/lazy.go:72), TemplateStore.LoadTemplates([]string{d.TemplatePath}) failed and the loader error is wrapped as 'failed to load templates'. Load failure means parse/compile problems in the referenced auth template (invalid YAML, unknown fields, operator compile errors) — a merely missing path produces the separate 'no templates found' error instead. The %w cause carries the underlying parse/compile detail.","triggerScenarios":"A dynamic secret whose TemplatePath references a template that fails to parse or compile under the current nuclei version; auth templates edited with syntax errors; schema drift after upgrades breaking previously-valid templates.","commonSituations":"Custom auth templates drifting from the current schema after nuclei upgrades; hand-edits introducing YAML/DSL errors; templates relying on removed fields.","solutions":["Validate the referenced template standalone: `nuclei -validate -t <TemplatePath>`","Fix the parse/compile error reported by the wrapped %w cause","Keep auth templates under the same templates root the store was built from","Re-validate auth templates after nuclei upgrades"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-validate the auth template before registering the dynamic secret\nif err := exec.Command(\"nuclei\", \"-validate\", \"-t\", d.TemplatePath).Run(); err != nil {\n    return fmt.Errorf(\"auth template %s fails validation\", d.TemplatePath)\n}","typeGuard":null,"tryCatchPattern":"tmpls, err := opts.TemplateStore.LoadTemplates([]string{d.TemplatePath})\nif err != nil {\n    return fmt.Errorf(\"cannot load auth template %s (validate it standalone): %w\", d.TemplatePath, err)\n}","preventionTips":["Run nuclei -validate on auth templates in CI","Re-validate after nuclei upgrades to catch schema drift","Keep auth templates in the store's templates root"],"tags":["go","nuclei","templates","auth-secrets","lazy-loading"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}