larksuite/cli · error

schema cannot declare both nullable and nonnullable

Error message

schema cannot declare both nullable and nonnullable

What it means

Schema tag parse guard: a field declares both nullable and nonnullable schema tokens, which are mutually exclusive nullability declarations.

Source

Thrown at shortcuts/common/typed_compile_args.go:428

		}
		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 == "" {
				return result, fmt.Errorf("schema default requires a JSON literal")
			}
			if !input {
				return result, fmt.Errorf("Data field cannot declare default")
			}
			var decoded any
			if err := json.Unmarshal([]byte(value), &decoded); err != nil {
				return result, fmt.Errorf("schema default is not valid JSON: %w", err)
			}
			result.defaultValue = typedInputDefault{Set: true, Value: decoded}
		case "enum":
			if !hasValue || value == "" {
				return result, fmt.Errorf("schema enum requires at least one value")

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Keep only one of nullable/nonnullable in the tag
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shortcuts/common/typed_compile_args.go:428 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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