larksuite/cli · error

%s

Error message

%s

What it means

Enum validation error from collectSchemaErrors: the value is not one of the schema's allowed `enum` values. The message includes the formatted value and allowed set, plus a 'did you mean' suggestion when a close match is found. It is wrapped into a typed flag validation error with a --print-schema hint.

Source

Thrown at shortcuts/sheets/flag_schema_validate.go:406

			c.add(fmt.Errorf("%sarray has %d items, maximum is %d", pathPrefix(path), len(arr), *schema.MaxItems)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint
		}
	}

	if len(schema.Enum) > 0 {
		matched := false
		for _, allowed := range schema.Enum {
			if jsonEqual(allowed, value) {
				matched = true
				break
			}
		}
		if !matched {
			msg := fmt.Sprintf("%svalue %s is not in enum %s",
				pathPrefix(path), formatJSONValue(value), formatEnum(schema.Enum))
			if hint := suggestEnumForError(value, schema.Enum); hint != "" {
				msg += fmt.Sprintf(` (did you mean %q?)`, hint)
			}
			c.add(fmt.Errorf("%s", msg)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint
		}
	}

	if len(schema.OneOf) > 0 {
		matched := false
		for _, sub := range schema.OneOf {
			probe := &schemaErrorCollector{}
			collectSchemaErrors(value, sub, path, probe)
			if len(probe.errs) == 0 {
				matched = true
				break
			}
		}
		if !matched {
			c.add(fmt.Errorf("%svalue does not match any of oneOf alternatives", pathPrefix(path))) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint
		}
	}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Use the exact suggested value shown in the 'did you mean' hint, if present.
  2. Run --print-schema to list the enum values and pick one verbatim.
  3. Fix casing/typos to match the enum exactly (comparison is case-sensitive).

Example fix

// before
--type 'spreadsheet'  // not in enum
// after
--type 'sheet'  // allowed enum value
Defensive patterns

Strategy: validation

Validate before calling

const allowed = ["sheet", "bitable"]; // from schema enum
if (!allowed.includes(value)) {
  throw new Error(`value must be one of ${allowed.join(", ")}, got ${value}`);
}

Type guard

function isEnumValue<T extends readonly string[]>(v: unknown, values: T): v is T[number] {
  return typeof v === "string" && (values as readonly string[]).includes(v);
}

Try / catch

try {
  runCommand(args);
} catch (e) {
  if (/did you mean/.test(e.message)) {
    // retry with the suggested enum value
  }
}

Prevention

When it happens

Trigger: Passing a flag value not present in the schema's enum list, e.g. `--type 'spreadsheet'` when the enum only allows `sheet`/`bitable`; the suggestion engine may propose the closest legal value.

Common situations: Typos or casing mismatches ('True' vs 'true'); using human-readable labels instead of enum identifiers; copying values from a different API's vocabulary.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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