{"record":{"id":"d84d0166da6d11e4","repo":"larksuite/cli","slug":"trimmed-equal-or-error-alias-s-requires-string","errorCode":null,"errorMessage":"trimmed_equal_or_error alias --%s requires string input","messagePattern":"trimmed_equal_or_error alias --(.+?) requires string input","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":366,"sourceCode":"\t\t}\n\t\tif _, duplicate := seenAliases[alias.Name]; duplicate {\n\t\t\treturn fmt.Errorf(\"duplicate alias --%s\", alias.Name)\n\t\t}\n\t\tseenAliases[alias.Name] = struct{}{}\n\t\tswitch alias.Mode {\n\t\tcase typedAliasNormalize:\n\t\t\tif alias.Conflict != \"\" {\n\t\t\t\treturn fmt.Errorf(\"normalize alias --%s cannot declare Conflict\", alias.Name)\n\t\t\t}\n\t\t\tif alias.Deprecated {\n\t\t\t\treturn fmt.Errorf(\"deprecated alias --%s must use independent mode so Cobra can emit its warning\", alias.Name)\n\t\t\t}\n\t\tcase typedAliasIndependent:\n\t\t\tswitch alias.Conflict {\n\t\t\tcase typedAliasCanonicalWins, typedAliasErrorIfBoth:\n\t\t\tcase typedAliasTrimmedEqualOrError:\n\t\t\t\tif indirectKind(field.valueType) != reflect.String {\n\t\t\t\t\treturn fmt.Errorf(\"trimmed_equal_or_error alias --%s requires string input\", alias.Name)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"independent alias --%s must declare a supported Conflict\", alias.Name)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"alias --%s has invalid Mode %q\", alias.Name, alias.Mode)\n\t\t}\n\t}\n\treturn nil\n}\n\ntype schemaTag struct {\n\trequired     bool\n\toptional     bool\n\tnullable     *bool\n\tdefaultValue typedInputDefault\n\tenum         []string\n\tformat       string","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L348-L384","documentation":"Thrown by validateInputCLI when an independent-mode alias declares conflict=trimmed_equal_or_error but the field's underlying type is not string. That conflict strategy compares flag values after whitespace trimming, which only makes sense for string fields, so the compiler rejects other kinds.","triggerScenarios":"A field like `Count int` tagged `alias:--num;mode=independent;conflict=trimmed_equal_or_error`; compileInput invokes validateInputCLI, indirectKind(field.valueType) != reflect.String triggers the error.","commonSituations":"Copying trimmed_equal_or_error onto a numeric or bool alias; changing a field's type from string to int without updating the alias conflict strategy.","solutions":["Change the field to a string type if trimmed comparison is required","Switch the Conflict to canonical-wins or error-if-both, which work for any type","Remove the alias if it is no longer needed"],"exampleFix":"// before\nCount int `cli:\"--count,alias:--c;mode=independent;conflict=trimmed_equal_or_error\"`\n// after\nCount int `cli:\"--count,alias:--c;mode=independent;conflict=canonical-wins\"`","handlingStrategy":"validation","validationCode":"if a.Mode == \"independent\" && a.Conflict == \"trimmed_equal_or_error\" && indirectKind(fieldType) != reflect.String {\n    return fmt.Errorf(\"alias --%s needs a string field for trimmed_equal_or_error\", a.Name)\n}","typeGuard":"func aliasSupportsTrimmedEqual(fieldType reflect.Type) bool {\n    k := fieldType\n    for k.Kind() == reflect.Ptr { k = k.Elem() }\n    return k.Kind() == reflect.String\n}","tryCatchPattern":null,"preventionTips":["Only use trimmed_equal_or_error on string (or *string) fields","Default independent aliases to conflict=canonical-wins unless trimming matters","Review field type changes together with their CLI tags"],"tags":["cli","flags","alias","type-mismatch","validation"],"backgroundTag":"invalid-flag-alias-configuration","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"}