{"record":{"id":"a6ec76c091b852a2","repo":"larksuite/cli","slug":"s-a6ec76","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/flag_schema_validate.go","lineNumber":406,"sourceCode":"\t\t\tc.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\n\t\t}\n\t}\n\n\tif len(schema.Enum) > 0 {\n\t\tmatched := false\n\t\tfor _, allowed := range schema.Enum {\n\t\t\tif jsonEqual(allowed, value) {\n\t\t\t\tmatched = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !matched {\n\t\t\tmsg := fmt.Sprintf(\"%svalue %s is not in enum %s\",\n\t\t\t\tpathPrefix(path), formatJSONValue(value), formatEnum(schema.Enum))\n\t\t\tif hint := suggestEnumForError(value, schema.Enum); hint != \"\" {\n\t\t\t\tmsg += fmt.Sprintf(` (did you mean %q?)`, hint)\n\t\t\t}\n\t\t\tc.add(fmt.Errorf(\"%s\", msg)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint\n\t\t}\n\t}\n\n\tif len(schema.OneOf) > 0 {\n\t\tmatched := false\n\t\tfor _, sub := range schema.OneOf {\n\t\t\tprobe := &schemaErrorCollector{}\n\t\t\tcollectSchemaErrors(value, sub, path, probe)\n\t\t\tif len(probe.errs) == 0 {\n\t\t\t\tmatched = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !matched {\n\t\t\tc.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\n\t\t}\n\t}\n","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/flag_schema_validate.go#L388-L424","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typos or casing mismatches ('True' vs 'true'); using human-readable labels instead of enum identifiers; copying values from a different API's vocabulary.","solutions":["Use the exact suggested value shown in the 'did you mean' hint, if present.","Run --print-schema to list the enum values and pick one verbatim.","Fix casing/typos to match the enum exactly (comparison is case-sensitive)."],"exampleFix":"// before\n--type 'spreadsheet'  // not in enum\n// after\n--type 'sheet'  // allowed enum value","handlingStrategy":"validation","validationCode":"const allowed = [\"sheet\", \"bitable\"]; // from schema enum\nif (!allowed.includes(value)) {\n  throw new Error(`value must be one of ${allowed.join(\", \")}, got ${value}`);\n}","typeGuard":"function isEnumValue<T extends readonly string[]>(v: unknown, values: T): v is T[number] {\n  return typeof v === \"string\" && (values as readonly string[]).includes(v);\n}","tryCatchPattern":"try {\n  runCommand(args);\n} catch (e) {\n  if (/did you mean/.test(e.message)) {\n    // retry with the suggested enum value\n  }\n}","preventionTips":["Copy enum values verbatim from --print-schema output.","Use union types / constants instead of free-form strings for enum flags.","Watch for case sensitivity: 'True' is not 'true'."],"tags":["sheets","schema-validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}