{"record":{"id":"1d9a207df96c9119","repo":"larksuite/cli","slug":"s-params-contains-duplicate-param-s","errorCode":null,"errorMessage":"%s.Params contains duplicate param --%s","messagePattern":"(.+?)\\.Params contains duplicate param --(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_contract.go","lineNumber":79,"sourceCode":"\t\tfor i, conditional := range authorization.ConditionalScopes {\n\t\t\tpath := fmt.Sprintf(\"Authorization.%s.ConditionalScopes[%d]\", identity, i)\n\t\t\tif len(conditional.Params) > 0 && conditional.When == \"\" {\n\t\t\t\treturn fmt.Errorf(\"%s.Params requires agent-readable When text\", path)\n\t\t\t}\n\t\t\tseen := make(map[string]struct{}, len(conditional.Params))\n\t\t\tfor j, param := range conditional.Params {\n\t\t\t\tif param == \"\" || param != strings.TrimSpace(param) {\n\t\t\t\t\treturn fmt.Errorf(\"%s.Params[%d] must be a non-blank trimmed param\", path, j)\n\t\t\t\t}\n\t\t\t\tfieldIndex, ok := fieldByName[param]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"%s references unknown param --%s\", path, param)\n\t\t\t\t}\n\t\t\t\tif fields[fieldIndex].cli.Hidden {\n\t\t\t\t\treturn fmt.Errorf(\"%s references hidden param --%s; use a public canonical param\", path, param)\n\t\t\t\t}\n\t\t\t\tif _, duplicate := seen[param]; duplicate {\n\t\t\t\t\treturn fmt.Errorf(\"%s.Params contains duplicate param --%s\", path, param)\n\t\t\t\t}\n\t\t\t\tseen[param] = struct{}{}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateOutput(definition typedOutputDefinition, dataShape typedValueShape) error {\n\tswitch definition.Mode {\n\tcase typedOutputGeneric, typedOutputFixedJSON:\n\tdefault:\n\t\treturn fmt.Errorf(\"Output.Mode %q is invalid\", definition.Mode)\n\t}\n\treturn nil\n}\n\nfunc decodeJSONPointerSegment(segment string) (string, bool) {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_contract.go#L61-L97","documentation":"Thrown when the same param appears more than once in a single conditional scope's Params list. Each conditional param must be unique; duplicates are redundant and rejected by the compiler's 'seen' set.","triggerScenarios":"ConditionalScopes entry with Params like []string{\"--doc-id\", \"--doc-id\"}.","commonSituations":"Duplicated entry during hand editing; merging param lists without dedup; generated slices appending an element twice.","solutions":["Remove the duplicate from the Params slice","Deduplicate the slice before constructing the definition"],"exampleFix":"// before\nParams: []string{\"--chat-id\", \"--message-id\", \"--chat-id\"}\n// after\nParams: []string{\"--chat-id\", \"--message-id\"}","handlingStrategy":"validation","validationCode":"seen := map[string]struct{}{}\nfor _, p := range cs.Params {\n  if _, dup := seen[p]; dup { return fmt.Errorf(\"duplicate scope param %q\", p) }\n  seen[p] = struct{}{}\n}","typeGuard":null,"tryCatchPattern":"if err := common.CompileTypedDefinition(def); err != nil {\n  return fmt.Errorf(\"duplicate conditional scope param: %w\", err)\n}","preventionTips":["Deduplicate Params slices programmatically when assembling them","Keep conditional scope params as short literal lists","Add a compile-all-definitions test"],"tags":["go","authorization","scopes","duplicate"],"backgroundTag":"shortcut-definition-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"}