{"record":{"id":"43cd9042f0c523c1","repo":"larksuite/cli","slug":"input-fields-d-name-q-is-not-a-canonical-flag-n","errorCode":null,"errorMessage":"Input.Fields[%d].Name %q is not a canonical flag name","messagePattern":"Input\\.Fields\\[(.+?)\\]\\.Name %q is not a canonical flag name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":31,"sourceCode":"\t\"strconv\"\n\t\"strings\"\n)\n\nvar (\n\tflagNamePattern  = regexp.MustCompile(`^[a-z0-9]+(?:-[a-z0-9]+)*$`)\n\taliasNamePattern = regexp.MustCompile(`^[a-z0-9][a-z0-9_-]*$`)\n)\n\nconst extensionCommandPkgPath = \"github.com/larksuite/cli/extension/command\"\n\nfunc compileInput(argsType reflect.Type, definition typedInputDefinition) ([]compiledInputField, map[string]int, error) {\n\tif argsType.Kind() != reflect.Struct {\n\t\treturn nil, nil, fmt.Errorf(\"Args must be a non-pointer struct, got %s\", argsType)\n\t}\n\tsupplements := make(map[string]typedInputField, len(definition.Fields))\n\tfor i, supplement := range definition.Fields {\n\t\tif !flagNamePattern.MatchString(supplement.Name) {\n\t\t\treturn nil, nil, fmt.Errorf(\"Input.Fields[%d].Name %q is not a canonical flag name\", i, supplement.Name)\n\t\t}\n\t\tif _, exists := supplements[supplement.Name]; exists {\n\t\t\treturn nil, nil, fmt.Errorf(\"Input.Fields contains duplicate flag %q\", supplement.Name)\n\t\t}\n\t\tsupplements[supplement.Name] = supplement\n\t}\n\tvar fields []compiledInputField\n\tseenGo := make(map[string]struct{})\n\tif err := collectArgFields(argsType, nil, false, &fields, seenGo, supplements); err != nil {\n\t\treturn nil, nil, err\n\t}\n\tfieldByName := make(map[string]int, len(fields))\n\tallNames := make(map[string]string, len(fields))\n\tfor i := range fields {\n\t\tfield := &fields[i]\n\t\tif previous, exists := allNames[field.name]; exists {\n\t\t\treturn nil, nil, fmt.Errorf(\"Args field %s flag --%s duplicates %s\", field.goName, field.name, previous)\n\t\t}","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L13-L49","documentation":"compileInput validates every supplemental Input.Fields entry name against flagNamePattern before merging it into compiled fields. Names must be canonical kebab-case flags (e.g. lower-case words separated by hyphens); anything else (underscores, CamelCase, leading dashes, spaces) is rejected with this error so help output and CLI parsing stay canonical.","triggerScenarios":"Adding a typedInputField to definition.Fields whose Name is e.g. \"task_id\", \"taskId\", \"--task-id\", or \"Task ID\" and compiling the definition.","commonSituations":"Reusing a JSON/Go field name as the flag name; hand-writing flag names with underscores from another convention; accidentally prefixing the name with '--' since the pattern expects the bare name.","solutions":["Rename the field to canonical kebab-case, e.g. \"task-id\".","Remove the '--' prefix — the framework adds dashes itself.","Verify against flagNamePattern (lowercase letters/digits, hyphen-separated) before compiling."],"exampleFix":"// before\n{Name: \"task_id\", Description: \"task id\"}\n// after\n{Name: \"task-id\", Description: \"task id\"}","handlingStrategy":"validation","validationCode":"var flagNameRe = regexp.MustCompile(`^[a-z][a-z0-9]*(-[a-z0-9]+)*$`)\nfunc validFlagNames(fields []typedInputField) error {\n  for _, f := range fields {\n    if !flagNameRe.MatchString(f.Name) {\n      return fmt.Errorf(\"flag %q is not canonical kebab-case\", f.Name)\n    }\n  }\n  return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use lower-kebab-case flag names without '--' prefix.","Avoid underscores and CamelCase in flag names.","Test-compile definitions in CI before release."],"tags":["go","flags","naming","validation"],"backgroundTag":"invalid-flag-name","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"}