{"record":{"id":"96f31cbd1422611a","repo":"larksuite/cli","slug":"schema-token-required-does-not-accept-a-value","errorCode":null,"errorMessage":"schema token required does not accept a value","messagePattern":"schema token required does not accept a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":415,"sourceCode":"func parseSchemaTag(raw string, valueType reflect.Type, input bool) (schemaTag, error) {\n\tvar result schemaTag\n\tif raw == \"\" {\n\t\treturn result, fmt.Errorf(\"schema tag must declare exactly one of required or optional\")\n\t}\n\tseen := make(map[string]struct{})\n\tfor _, token := range strings.Split(raw, \";\") {\n\t\tif token == \"\" || token != strings.TrimSpace(token) {\n\t\t\treturn result, fmt.Errorf(\"schema contains blank or untrimmed token %q\", token)\n\t\t}\n\t\tkey, value, hasValue := strings.Cut(token, \"=\")\n\t\tif _, duplicate := seen[key]; duplicate {\n\t\t\treturn result, fmt.Errorf(\"schema token %q is duplicated\", key)\n\t\t}\n\t\tseen[key] = struct{}{}\n\t\tswitch key {\n\t\tcase \"required\":\n\t\t\tif hasValue {\n\t\t\t\treturn result, fmt.Errorf(\"schema token required does not accept a value\")\n\t\t\t}\n\t\t\tresult.required = true\n\t\tcase \"optional\":\n\t\t\tif hasValue {\n\t\t\t\treturn result, fmt.Errorf(\"schema token optional does not accept a value\")\n\t\t\t}\n\t\t\tresult.optional = true\n\t\tcase \"nullable\", \"nonnullable\":\n\t\t\tif hasValue {\n\t\t\t\treturn result, fmt.Errorf(\"schema token %s does not accept a value\", key)\n\t\t\t}\n\t\t\tif result.nullable != nil {\n\t\t\t\treturn result, fmt.Errorf(\"schema cannot declare both nullable and nonnullable\")\n\t\t\t}\n\t\t\tv := key == \"nullable\"\n\t\t\tresult.nullable = &v\n\t\tcase \"default\":\n\t\t\tif !hasValue || value == \"\" {","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L397-L433","documentation":"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.","triggerScenarios":"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.","commonSituations":"Authors generalizing all tokens to key=value form; translating from JSON-schema boolean syntax; mechanical search-and-replace adding values to flags.","solutions":["Write the bare token `required` with no value","Use `optional` instead if intent was to express optionality explicitly","Remove the `=value` suffix"],"exampleFix":"// before\nName string `cli:\"--name;schema:\\\"required=true\\\"\"`\n// after\nName string `cli:\"--name;schema:\\\"required\\\"\"`","handlingStrategy":"validation","validationCode":"if key == \"required\" && strings.Contains(token, \"=\") {\n    return fmt.Errorf(\"required must be a bare token\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write required/optional as bare tokens without values","Document that required/optional are markers, not booleans","Lint for `required=` and `optional=` substrings in tags"],"tags":["cli","schema","tags","grammar","validation"],"backgroundTag":"schema-validation-failed","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"}