projectdiscovery/nuclei · error
validation failed for these fields
Error message
validation failed for these fields
What it means
After YAML decoding, the wrapper (pkg/utils/yaml/yaml_decode_wrapper.go:171) runs go-playground/validator's validate.Struct and collects every violation as `Namespace(): Tag()` pairs, wrapped as 'validation failed for these fields'. The YAML parsed successfully; one or more struct `validate` tags (required, oneof, min, etc.) were violated. The namespaces in the message name the exact failing field paths and the tag that failed.
Source
Thrown at pkg/utils/yaml/yaml_decode_wrapper.go:171
// DecodeAndValidate is a wrapper for yaml Decode adding struct validation
func DecodeAndValidate(r io.Reader, v interface{}) error {
if err := NewDecoder(r).Decode(v); err != nil {
return err
}
if validate == nil {
validate = validator.New()
}
if err := validate.Struct(v); err != nil {
if _, ok := err.(*validator.InvalidValidationError); ok {
return err
}
errs := []string{}
for _, err := range err.(validator.ValidationErrors) {
errs = append(errs, err.Namespace()+": "+err.Tag())
}
return errors.Wrap(errors.New(strings.Join(errs, ", ")), "validation failed for these fields")
}
return nil
}
func normalizeDupMappingKeys(node *yaml.Node) {
node = unwrapDoc(node)
if node == nil {
return
}
switch node.Kind {
case yaml.DocumentNode:
for _, child := range node.Content {
normalizeDupMappingKeys(child)
}
case yaml.SequenceNode:
for _, child := range node.Content {
normalizeDupMappingKeys(child)View on GitHub (pinned to 265b3a3dec)
Solutions
- Read the namespace list — each entry names the failing field path and the failed tag
- Fix the named field (e.g. set the enum value to one of the allowed choices)
- Run `nuclei -validate` to catch violations before scanning
- Re-validate existing template sets after nuclei upgrades
Defensive patterns
Strategy: try-catch
Try / catch
if err := yaml.DecodeStrict(bytes.NewReader(data), &v); err != nil {
var vErrs validator.ValidationErrors
if errors.As(err, &vErrs) {
for _, fe := range vErrs {
log.Printf("field %s failed %s", fe.Namespace(), fe.Tag())
}
}
return err
} Prevention
- Treat the namespace list in the message as the fix list: address each named field
- Run nuclei -validate in CI to catch constraint violations pre-scan
- After upgrading nuclei, re-validate templates because validate tags evolve
When it happens
Trigger: Decoding a template/config struct through the yaml decode wrapper where a required field is empty, an enum (oneof) field holds an out-of-list value, or a numeric min/max/dive constraint fails.
Common situations: Templates missing required info fields or with typo'd enum values (e.g. severity); schema drift after upgrading nuclei adds new validate tags to old templates; hand-built config structs decoded with the wrapper.
Related errors
- Invalid protocol type: {valueToMap}
- invalid workflow with no templates or tags
- include directive preprocessing is disabled
- could not parse profile YAML: %w
- could not marshal inline secrets: %w
AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15).
Data as JSON: /api/errors/68867811d37c9928.
Report an issue: GitHub.