{"record":{"id":"00a1272405f37725","repo":"larksuite/cli","slug":"schema-contains-blank-or-untrimmed-token-q","errorCode":null,"errorMessage":"schema contains blank or untrimmed token %q","messagePattern":"schema contains blank or untrimmed token %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":405,"sourceCode":"\tminimum      *float64\n\tmaximum      *float64\n\tminItems     *int\n\tmaxItems     *int\n}\n\nfunc schemaHasShapeConstraints(schema schemaTag) bool {\n\treturn len(schema.enum) > 0 || schema.format != \"\" || hasStringConstraints(schema) || hasNumberConstraints(schema) || hasItemConstraints(schema)\n}\n\nfunc 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\":","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L387-L423","documentation":"Thrown by parseSchemaTag when a semicolon-separated schema token is empty or has leading/trailing whitespace. The parser enforces strict, well-trimmed token grammar so tags remain canonical and diffable.","triggerScenarios":"Tags like `schema:\"required;\"` (trailing semicolon -> empty token), `\"required; enum=a\"` (space after semicolon), or `\" required\"` (leading space); any token where token != strings.TrimSpace(token) or token == \"\".","commonSituations":"Multi-token tags wrapped across source lines with stray spaces; gofmt-less hand edits leaving dangling semicolons; copy-paste from docs introducing spaces around separators.","solutions":["Remove trailing/leading semicolons and extra whitespace between tokens","Write tokens as `key=value` pairs separated by plain `;` with no spaces","Reformat the tag onto one clean line"],"exampleFix":"// before\nName string `cli:\"--name;schema:\\\"required; enum=a, b\\\"\"`\n// after\nName string `cli:\"--name;schema:\\\"required;enum=a,b\\\"\"`","handlingStrategy":"validation","validationCode":"for _, tok := range strings.Split(tag, \";\") {\n    if tok == \"\" || tok != strings.TrimSpace(tok) {\n        return fmt.Errorf(\"blank or untrimmed schema token %q\", tok)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid spaces around `;` separators in schema tags","Remove trailing semicolons after the last token","Format struct tags on a single line and run gofmt"],"tags":["cli","schema","tags","whitespace","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"}