{"record":{"id":"9b0f961adf71da48","repo":"larksuite/cli","slug":"schema-token-q-is-duplicated","errorCode":null,"errorMessage":"schema token %q is duplicated","messagePattern":"schema token %q is duplicated","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":409,"sourceCode":"}\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\":\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 {","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L391-L427","documentation":"Thrown by parseSchemaTag when the same schema token key appears more than once in the tag. Duplicate keys would make constraint precedence ambiguous, so the parser tracks seen keys and rejects repeats.","triggerScenarios":"A tag like `schema:\"required;required\"` or `\"enum=a;enum=b\"` — after strings.Cut, the key is found in the seen map.","commonSituations":"Appending a second value to a token without merging it (e.g. two enum tokens instead of one comma-separated value); merge conflicts concatenating both halves of an edited tag.","solutions":["Remove the duplicate token","Merge repeated value tokens into one (e.g. `enum=a,b` instead of two enum tokens)","Keep each key at most once per schema tag"],"exampleFix":"// before\nName string `cli:\"--name;schema:\\\"required;enum=a;enum=b\\\"\"`\n// after\nName string `cli:\"--name;schema:\\\"required;enum=a,b\\\"\"`","handlingStrategy":"validation","validationCode":"seen := map[string]bool{}\nfor _, tok := range strings.Split(tag, \";\") {\n    key, _, _ := strings.Cut(tok, \"=\")\n    if seen[key] { return fmt.Errorf(\"duplicate schema token %q\", key) }\n    seen[key] = true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Merge repeated value tokens (enum=a;enum=b -> enum=a,b)","Review merge-conflict resolutions in struct tag lines","Enforce one-key-per-tag in a lint rule"],"tags":["cli","schema","tags","duplicate","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"}