go-playground/validator · error

Unrecognized parameter:

Error message

Unrecognized parameter: 

What it means

The SpiceDB tag validator (`isSpiceDB`, tags `spicedb_id`/`spicedb_type` with a `param` selector) only recognizes parameters "id", "type", or empty. Any other parameter value reaches a panic('Unrecognized parameter: ' + param).

Source

Thrown at baked_in.go:3466

	val := fl.Field().String()
	return mongodbConnectionRegex().MatchString(val)
}

// isSpiceDB is the validation function for validating if the current field's value is valid for use with Authzed SpiceDB in the indicated way
func isSpiceDB(fl FieldLevel) bool {
	val := fl.Field().String()
	param := fl.Param()

	switch param {
	case "permission":
		return spicedbPermissionRegex().MatchString(val)
	case "type":
		return spicedbTypeRegex().MatchString(val)
	case "id", "":
		return spicedbIDRegex().MatchString(val)
	}

	panic("Unrecognized parameter: " + param)
}

// isCreditCard is the validation function for validating if the current field's value is a valid credit card number
func isCreditCard(fl FieldLevel) bool {
	val := fl.Field().String()
	var creditCard bytes.Buffer
	segments := strings.Split(val, " ")
	for _, segment := range segments {
		if len(segment) < 3 {
			return false
		}
		creditCard.WriteString(segment)
	}

	ccDigits := strings.Split(creditCard.String(), "")
	size := len(ccDigits)
	if size < 12 || size > 19 {
		return false

View on GitHub (pinned to facf128d2e)

Solutions

  1. Use only the documented tags `spicedb_id` and `spicedb_type`
  2. Fix the alias/tag registration so the param is "id" or "type"
  3. Register your own validator function instead of reusing isSpiceDB with a custom name
  4. Add recover() around validation during development to surface the bad tag early

Example fix

// before
ID string `validate:"spicedb_typ"`
// after
ID string `validate:"spicedb_id"`
Defensive patterns

Strategy: validation

Validate before calling

allowed := map[string]bool{"spicedb_id": true, "spicedb_type": true}
// verify struct tags before validating:
for _, f := range reflect.TypeOf(obj).Fields() {
    tag := f.Tag.Get("validate")
    for _, t := range strings.Split(tag, ",") {
        if strings.HasPrefix(t, "spicedb_") && !allowed[t] {
            panic("bad spicedb tag: " + t)
        }
    }
}

Try / catch

defer func() {
    if r := recover(); r != nil {
        if strings.HasPrefix(fmt.Sprint(r), "Unrecognized parameter") {
            err = fmt.Errorf("bad validator tag: %v", r)
        } else { panic(r) }
    }
}()

Prevention

When it happens

Trigger: Using a tag like `spicedb_foo` or registering `isSpiceDB` under a name/alias whose parameter extraction yields an unsupported string, e.g. a misspelled `spicedb_id` variant or custom registration passing an unexpected param.

Common situations: Typo in the tag name (e.g. `spicedb_typ`), hand-rolled alias expansion producing an unexpected param, or registering the function under a new tag name without updating its switch.

Related errors


AI-assisted analysis of go-playground/validator@facf128d2e (2026-09-02). Data as JSON: /api/errors/2973d653832f71d6. Report an issue: GitHub.