{"record":{"id":"1052145d60e2262f","repo":"projectdiscovery/nuclei","slug":"the-s-file-for-payload-s-does-not-exist-or-does","errorCode":null,"errorMessage":"the %s file for payload %s does not exist or does not contain enough elements","messagePattern":"the (.+?) file for payload (.+?) does not exist or does not contain enough elements","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/protocols/common/generators/validate.go","lineNumber":62,"sourceCode":"\t\t\t// 2. /home/user/nuclei-templates/cves/my-payload.txt\n\t\t\t// 3. /home/user/nuclei-templates/my-payload.txt\n\t\t\t// 4. /home/user/my-payload.txt\n\t\t\t// 5. /home/my-payload.txt\n\t\t\tchanged := false\n\n\t\t\tdir, _ := filepath.Split(templatePath)\n\t\t\ttemplatePathInfo, _ := folderutil.NewPathInfo(dir)\n\t\t\tpayloadPathsToProbe, _ := templatePathInfo.MeshWith(payloadType)\n\n\t\t\tfor _, payloadPath := range payloadPathsToProbe {\n\t\t\t\tif fileutil.FileExists(payloadPath) {\n\t\t\t\t\tpayloads[name] = payloadPath\n\t\t\t\t\tchanged = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !changed {\n\t\t\t\treturn fmt.Errorf(\"the %s file for payload %s does not exist or does not contain enough elements\", payloadType, name)\n\t\t\t}\n\t\tcase interface{}:\n\t\t\tloadedPayloads := types.ToStringSlice(payloadType)\n\t\t\tif len(loadedPayloads) == 0 {\n\t\t\t\treturn fmt.Errorf(\"the payload %s does not contain enough elements\", name)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"the payload %s has invalid type\", name)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":44,"sourceCodeEnd":75,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/protocols/common/generators/validate.go#L44-L75","documentation":"Template compilation error from PayloadGenerator.validate (pkg/protocols/common/generators/validate.go:62). For a payload given as a string (not inline list), nuclei checks: absolute existence, existence under the default templates dir, then MeshWith probing of every ancestor path of the template's directory. If no probe finds the file, this error names the payload string and its key. It is skipped when the payload contains newlines (inline multiline payload) or when a custom LoadHelperFileFunction is set.","triggerScenarios":"`payloads: {username: usernames.txt}` where usernames.txt is neither next to the template, in any ancestor directory up to root, nor inside the nuclei-templates directory — e.g. the file sits in an unrelated folder, was renamed, or the templates repo was copied without helper files.","commonSituations":"Downloading a template alone without its companion payload file; templates moved out of the standard nuclei-templates checkout losing relative resolution; CI copying only *.yaml; case-sensitive filesystems vs Windows-authored filenames.","solutions":["Place the payload file in the template's directory (or an ancestor of it) so MeshWith resolves it, or use an absolute path","If distributing templates, ship helper files together and keep relative paths inside the templates root","Alternatively inline the payload as a YAML list or newline-joined string (strings containing \\n skip file validation)","Verify quickly: `ls` the file relative to the template dir, and re-run `nuclei -validate -t template.yaml`"],"exampleFix":"# before\npayloads:\n  users: /opt/wordlists/arbitrary-spot/users.txt  # moved/missing\n# after\npayloads:\n  users:\n    - admin\n    - root\n    - test","handlingStrategy":"validation","validationCode":"import fd \"github.com/projectdiscovery/utils/file\"\n\nfunc payloadResolvable(name, path, tplDir string) bool {\n\tif fd.FileExists(path) { return true }\n\tif fd.FileExists(filepath.Join(config.DefaultConfig.GetTemplateDir(), path)) { return true }\n\tfor _, p := range meshPaths(tplDir, path) { if fd.FileExists(p) { return true } }\n\treturn false\n}","typeGuard":"func payloadSpecValid(p interface{}) bool {\n\tswitch v := p.(type) {\n\tcase string:\n\t\treturn strings.ContainsRune(v, '\\n') || fd.FileExists(v)\n\tcase []interface{}:\n\t\treturn len(v) > 0\n\t}\n\treturn false\n}","tryCatchPattern":"if err := generator.Validate(payloads, templatePath); err != nil {\n\tif strings.Contains(err.Error(), \"does not exist or does not contain enough elements\") {\n\t\t// resolve/ship the named helper file, or inline the payload as a list\n\t}\n\treturn err\n}","preventionTips":["Ship payload files alongside templates in the same repo tree","Inline small payload sets as YAML lists to remove file dependencies","On case-sensitive filesystems, verify exact filename casing","CI: -validate every template in a checkout that includes helper files"],"tags":["payloads","generator","file-not-found","template","compile-time"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}