projectdiscovery/nuclei · error

the %s file for payload %s does not exist or does not contai

Error message

the %s file for payload %s does not exist or does not contain enough elements

What it means

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.

Source

Thrown at pkg/protocols/common/generators/validate.go:62

			// 2. /home/user/nuclei-templates/cves/my-payload.txt
			// 3. /home/user/nuclei-templates/my-payload.txt
			// 4. /home/user/my-payload.txt
			// 5. /home/my-payload.txt
			changed := false

			dir, _ := filepath.Split(templatePath)
			templatePathInfo, _ := folderutil.NewPathInfo(dir)
			payloadPathsToProbe, _ := templatePathInfo.MeshWith(payloadType)

			for _, payloadPath := range payloadPathsToProbe {
				if fileutil.FileExists(payloadPath) {
					payloads[name] = payloadPath
					changed = true
					break
				}
			}
			if !changed {
				return fmt.Errorf("the %s file for payload %s does not exist or does not contain enough elements", payloadType, name)
			}
		case interface{}:
			loadedPayloads := types.ToStringSlice(payloadType)
			if len(loadedPayloads) == 0 {
				return fmt.Errorf("the payload %s does not contain enough elements", name)
			}
		default:
			return fmt.Errorf("the payload %s has invalid type", name)
		}
	}
	return nil
}

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Place the payload file in the template's directory (or an ancestor of it) so MeshWith resolves it, or use an absolute path
  2. If distributing templates, ship helper files together and keep relative paths inside the templates root
  3. Alternatively inline the payload as a YAML list or newline-joined string (strings containing \n skip file validation)
  4. Verify quickly: `ls` the file relative to the template dir, and re-run `nuclei -validate -t template.yaml`

Example fix

# before
payloads:
  users: /opt/wordlists/arbitrary-spot/users.txt  # moved/missing
# after
payloads:
  users:
    - admin
    - root
    - test
Defensive patterns

Strategy: validation

Validate before calling

import fd "github.com/projectdiscovery/utils/file"

func payloadResolvable(name, path, tplDir string) bool {
	if fd.FileExists(path) { return true }
	if fd.FileExists(filepath.Join(config.DefaultConfig.GetTemplateDir(), path)) { return true }
	for _, p := range meshPaths(tplDir, path) { if fd.FileExists(p) { return true } }
	return false
}

Type guard

func payloadSpecValid(p interface{}) bool {
	switch v := p.(type) {
	case string:
		return strings.ContainsRune(v, '\n') || fd.FileExists(v)
	case []interface{}:
		return len(v) > 0
	}
	return false
}

Try / catch

if err := generator.Validate(payloads, templatePath); err != nil {
	if strings.Contains(err.Error(), "does not exist or does not contain enough elements") {
		// resolve/ship the named helper file, or inline the payload as a list
	}
	return err
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/1052145d60e2262f. Report an issue: GitHub.