{"record":{"id":"f191e659d7c31e4b","repo":"larksuite/cli","slug":"unknown-cli-token-q","errorCode":null,"errorMessage":"unknown cli token %q","messagePattern":"unknown cli token %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":538,"sourceCode":"\tseen := make(map[string]struct{})\n\tfor _, token := range strings.Split(raw, \";\") {\n\t\tkey, value, ok := strings.Cut(token, \"=\")\n\t\tif !ok || value == \"\" || token != strings.TrimSpace(token) {\n\t\t\treturn result, fmt.Errorf(\"invalid cli token %q\", token)\n\t\t}\n\t\tif _, duplicate := seen[key]; duplicate {\n\t\t\treturn result, fmt.Errorf(\"cli token %q is duplicated\", key)\n\t\t}\n\t\tseen[key] = struct{}{}\n\t\tswitch key {\n\t\tcase \"sources\":\n\t\t\tfor _, source := range strings.Split(value, \"|\") {\n\t\t\t\tresult.ValueSources = append(result.ValueSources, typedValueSource(source))\n\t\t\t}\n\t\tcase \"encoding\":\n\t\t\tresult.Encoding = typedCLIEncoding(value)\n\t\tdefault:\n\t\t\treturn result, fmt.Errorf(\"unknown cli token %q\", key)\n\t\t}\n\t}\n\treturn result, nil\n}\n\nfunc parseFiniteFloat(value string) (float64, error) {\n\treturn parseFiniteFloatBits(value, 64)\n}\n\nfunc parseFiniteFloatBits(value string, bits int) (float64, error) {\n\tparsed, err := strconv.ParseFloat(value, bits)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif math.IsNaN(parsed) || math.IsInf(parsed, 0) {\n\t\treturn 0, fmt.Errorf(\"must be finite\")\n\t}\n\treturn parsed, nil","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L520-L556","documentation":"parseCLITag only accepts the tokens `sources` (pipe-separated value list) and `encoding`; any other key in a `cli:\"...\"` tag is rejected with this error. This keeps the typed-input CLI metadata grammar closed so typos cannot silently become no-op options. It surfaces as a build-time declaration error when the command set is compiled.","triggerScenarios":"Writing an unrecognized token in a cli tag, e.g. `cli:\"source=a|b\"` (singular) or `cli:\"env=prod\"`; a misspelling like `encodings=json`.","commonSituations":"Typo when hand-writing tags; inventing options that the tag grammar does not support; copying tag syntax from a different framework.","solutions":["Replace the unknown token with a supported key: `sources` or `encoding`","Check spelling against the supported keys in typed_compile_args.go","Move any non-tag configuration to a supported struct tag or code, not the cli tag"],"exampleFix":"// before\nField string `cli:\"source=a|b\"`\n// after\nField string `cli:\"sources=a|b\"`","handlingStrategy":"validation","validationCode":"var allowedCLITokens = map[string]bool{\"sources\": true, \"encoding\": true}\nfunc validateCLITagTokens(raw string) error {\n\tfor _, tok := range strings.Split(raw, \";\") {\n\t\tkey, _, ok := strings.Cut(tok, \"=\")\n\t\tif !ok || !allowedCLITokens[key] { return fmt.Errorf(\"unknown cli token %q\", key) }\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use the documented keys: sources and encoding","Copy tag examples from the repository rather than inventing syntax","Add a compile-time test that parses all cli tags in the package"],"tags":["go","struct-tags","cli","validation"],"backgroundTag":"unknown-struct-tag-option","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"}