apache/answer · error
validate check exception
Error message
validate check exception
What it means
Check runs the go-playground/validator Struct validation on a model and translates field errors into FormErrorField entries. If the returned error is NOT a validator.ValidationErrors (i.e. an unexpected internal validator failure such as a bad tag or wrong input type), it logs and returns the generic 'validate check exception'.
Source
Thrown at internal/base/validator/validator.go:215
continue
}
firstRune := []rune(field.ErrorMsg)[0]
if !unicode.IsLetter(firstRune) || !unicode.Is(unicode.Latin, firstRune) {
continue
}
upperFirstRune := unicode.ToUpper(firstRune)
field.ErrorMsg = string(upperFirstRune) + field.ErrorMsg[1:]
if !strings.HasSuffix(field.ErrorMsg, ".") {
field.ErrorMsg += "."
}
}
}()
err = m.Validate.Struct(value)
if err != nil {
var valErrors validator.ValidationErrors
if !errors.As(err, &valErrors) {
log.Error(err)
return nil, errors.New("validate check exception")
}
for _, fieldError := range valErrors {
errField := &FormErrorField{
ErrorField: fieldError.Field(),
ErrorMsg: fieldError.Translate(m.Tran),
}
// get original tag name from value for set err field key.
structNamespace := fieldError.StructNamespace()
_, fieldName, found := strings.Cut(structNamespace, ".")
if found {
originalTag := getObjectTagByFieldName(value, fieldName)
if len(originalTag) > 0 {
errField.ErrorField = originalTag
}
}
errFields = append(errFields, errField)View on GitHub (pinned to 3b9f137061)
Solutions
- Inspect the server log above this error — the underlying validator error is logged via log.Error(err).
- Fix the struct's validate tags (e.g. register missing custom validators with validator.RegisterValidation).
- Ensure the value passed to Check is a struct or pointer to struct.
- Pin/align the go-playground/validator version and the translator setup.
Example fix
// before Answer `validate:"omitempty,unknown_rule"` // after Answer string `validate:"omitempty,min=1,max=500"`
Defensive patterns
Strategy: validation
Validate before calling
v := validator.New()
v.RegisterTagNameFunc(func(fld reflect.StructField) string { return fld.Tag.Get("json") })
if err := v.Struct(MyRequest{}); err != nil {
var ve validator.ValidationErrors
if !errors.As(err, &ve) { log.Fatalf("validator misconfigured: %v", err) }
} Type guard
func isStructPtr(v any) bool {
rv := reflect.ValueOf(v)
return rv.Kind() == reflect.Ptr && rv.Elem().Kind() == reflect.Struct
} Try / catch
form, err := validator.Check(req)
if err != nil {
if err.Error() == "validate check exception" {
log.Errorf("validator internal failure: %v", err)
return 500 // not a user input problem
}
} Prevention
- Only pass structs (or struct pointers) to Check
- Register every custom validator tag you use in tags
- Validate tag syntax in unit tests for request structs
- Keep go-playground/validator and translator deps aligned
When it happens
Trigger: Passing a value whose type validator can't struct-validate (non-struct, nil pointer misfire, map without register), or a struct with an invalid/misconfigured validate tag that makes the validator return a non-ValidationErrors error.
Common situations: Developer adds a custom validator tag without registering it, misuses tags like `validate:"-"` incorrectly, passes a non-struct to Check, or upgrades go-playground/validator causing tag incompatibilities.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- base.request_format_error
- error.password.space_invalid
- decode image config error: %v
- image size too large
- the password does not satisfy the current policy requirement
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/3c038d4b29147a52.
Report an issue: GitHub.