go-playground/validator · error
Bad field type %s:%s
Error message
Bad field type %s:%s
What it means
Panics inside isUnique's default branch when the sibling field named by the unique tag parameter exists but its reflect.Kind differs from the field being validated. unique performs a direct value comparison between the two fields, which is only meaningful for like kinds; the panic message prints both types (field type : unique field type) to expose the mismatch.
Source
Thrown at baked_in.go:484
}
if _, ok := seen[key]; ok {
return false
}
seen[key] = struct{}{}
}
return true
default:
if parent := fl.Parent(); parent.Kind() == reflect.Struct {
uniqueField := parent.FieldByName(param)
if !uniqueField.IsValid() {
panic(fmt.Sprintf("Bad field name provided %s", param))
}
if uniqueField.Kind() != field.Kind() {
panic(fmt.Sprintf("Bad field type %s:%s", field.Type(), uniqueField.Type()))
}
return getValue(field) != getValue(uniqueField)
}
panic(fmt.Sprintf("Bad field type %s", field.Type()))
}
}
// isMAC is the validation function for validating if the field's value is a valid MAC address.
func isMAC(fl FieldLevel) bool {
_, err := net.ParseMAC(fl.Field().String())
return err == nil
}
// isCIDRv4 is the validation function for validating if the field's value is a valid v4 CIDR address.
func isCIDRv4(fl FieldLevel) bool {View on GitHub (pinned to facf128d2e)
Solutions
- Make both fields the same type so the comparison is valid
- Convert one field's type to match the other (e.g. int32 vs int64, or one side a pointer)
- Write a custom validator if cross-type uniqueness comparison is genuinely needed
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at baked_in.go:484 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of go-playground/validator@facf128d2e (2026-09-02).
Data as JSON: /api/errors/0388344df2e86a16.
Report an issue: GitHub.