{"record":{"id":"dec5ea446565f3f7","repo":"larksuite/cli","slug":"input-relations-d-repeats-param-s","errorCode":null,"errorMessage":"Input.Relations[%d] repeats param --%s","messagePattern":"Input\\.Relations\\[(.+?)\\] repeats param --(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_contract.go","lineNumber":43,"sourceCode":"\t\t}\n\t\tif exact > 0 && len(definition.Params) != exact || exact == 0 && len(definition.Params) < minimum {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] kind %s has invalid param count %d\", i, definition.Kind, len(definition.Params))\n\t\t}\n\t\tif definition.Presence != typedPresenceExplicit && definition.Presence != typedPresenceNonZero {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d].Presence %q is invalid\", i, definition.Presence)\n\t\t}\n\t\tif definition.Stage != typedStageSourcePreRun && definition.Stage != typedStageAfterPrepare {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d].Stage %q is invalid\", i, definition.Stage)\n\t\t}\n\t\tcompiled := compiledRelation{kind: definition.Kind, presence: definition.Presence, stage: definition.Stage}\n\t\tlocal := make(map[string]struct{})\n\t\tfor _, name := range definition.Params {\n\t\t\tfield, ok := fieldByName[name]\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] references unknown param --%s\", i, name)\n\t\t\t}\n\t\t\tif _, duplicate := local[name]; duplicate {\n\t\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] repeats param --%s\", i, name)\n\t\t\t}\n\t\t\tlocal[name] = struct{}{}\n\t\t\tcompiled.fields = append(compiled.fields, field)\n\t\t}\n\t\tkeyBytes, _ := json.Marshal(definition)\n\t\tkey := string(keyBytes)\n\t\tif _, duplicate := seen[key]; duplicate {\n\t\t\treturn nil, fmt.Errorf(\"Input.Relations[%d] duplicates an earlier relation\", i)\n\t\t}\n\t\tseen[key] = struct{}{}\n\t\tresult = append(result, compiled)\n\t}\n\treturn result, nil\n}\n\nfunc compileAuthorization(definition typedAuthorizationDefinition, fields []compiledInputField, fieldByName map[string]int) error {\n\tfor identity, authorization := range definition.Identities {\n\t\tfor i, conditional := range authorization.ConditionalScopes {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_contract.go#L25-L61","documentation":"Thrown when a single relation in Input.Relations lists the same param name more than once. Each relation param must be unique; the compiler tracks a per-relation 'local' set and rejects repeats so the relation's field list stays unambiguous.","triggerScenarios":"A Relation's Params slice contains the same flag name twice, e.g. Params: []string{\"--chat_id\", \"--chat_id\"}.","commonSituations":"Accidentally duplicating an entry while editing the params list; generating params programmatically and appending the same field twice; merging two param lists without dedup.","solutions":["Remove the duplicate entry from the relation's Params slice","Deduplicate params programmatically before building the definition if they are assembled at runtime (in code, not a user flag)"],"exampleFix":"// before\nParams: []string{\"--message-id\", \"--message-id\"}\n// after\nParams: []string{\"--message-id\"}","handlingStrategy":"validation","validationCode":"seen := map[string]struct{}{}\nfor _, name := range rel.Params {\n  if _, dup := seen[name]; dup { return fmt.Errorf(\"duplicate param %q\", name) }\n  seen[name] = struct{}{}\n}","typeGuard":null,"tryCatchPattern":"if err := common.CompileTypedDefinition(def); err != nil {\n  return fmt.Errorf(\"relation param duplicate: %w\", err)\n}","preventionTips":["Build Params via a dedup helper before constructing the Relation","Keep param lists short and hand-reviewable","Add a compile-all-definitions test"],"tags":["go","shortcut-definition","validation","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"}