larksuite/cli · error

schema token required does not accept a value

Error message

schema token required does not accept a value

What it means

Thrown by parseSchemaTag when the required token is written with a value, e.g. `required=true`. required is a bare boolean marker and accepts no `=` value; the parser's switch on key rejects hasValue for it.

Source

Thrown at shortcuts/common/typed_compile_args.go:415

func parseSchemaTag(raw string, valueType reflect.Type, input bool) (schemaTag, error) {
	var result schemaTag
	if raw == "" {
		return result, fmt.Errorf("schema tag must declare exactly one of required or optional")
	}
	seen := make(map[string]struct{})
	for _, token := range strings.Split(raw, ";") {
		if token == "" || token != strings.TrimSpace(token) {
			return result, fmt.Errorf("schema contains blank or untrimmed token %q", token)
		}
		key, value, hasValue := strings.Cut(token, "=")
		if _, duplicate := seen[key]; duplicate {
			return result, fmt.Errorf("schema token %q is duplicated", key)
		}
		seen[key] = struct{}{}
		switch key {
		case "required":
			if hasValue {
				return result, fmt.Errorf("schema token required does not accept a value")
			}
			result.required = true
		case "optional":
			if hasValue {
				return result, fmt.Errorf("schema token optional does not accept a value")
			}
			result.optional = true
		case "nullable", "nonnullable":
			if hasValue {
				return result, fmt.Errorf("schema token %s does not accept a value", key)
			}
			if result.nullable != nil {
				return result, fmt.Errorf("schema cannot declare both nullable and nonnullable")
			}
			v := key == "nullable"
			result.nullable = &v
		case "default":
			if !hasValue || value == "" {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Write the bare token `required` with no value
  2. Use `optional` instead if intent was to express optionality explicitly
  3. Remove the `=value` suffix

Example fix

// before
Name string `cli:"--name;schema:\"required=true\""`
// after
Name string `cli:"--name;schema:\"required\""`
Defensive patterns

Strategy: validation

Validate before calling

if key == "required" && strings.Contains(token, "=") {
    return fmt.Errorf("required must be a bare token")
}

Prevention

When it happens

Trigger: A tag like `schema:"required=true"` or `"required:yes"`-style key=value forms; parseSchemaTag cuts the token on '=' and finds hasValue true for key required.

Common situations: Authors generalizing all tokens to key=value form; translating from JSON-schema boolean syntax; mechanical search-and-replace adding values to flags.

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


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/96f31cbd1422611a. Report an issue: GitHub.