larksuite/cli · error

Input.Relations[%d] repeats param --%s

Error message

Input.Relations[%d] repeats param --%s

What it means

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.

Source

Thrown at shortcuts/common/typed_compile_contract.go:43

		}
		if exact > 0 && len(definition.Params) != exact || exact == 0 && len(definition.Params) < minimum {
			return nil, fmt.Errorf("Input.Relations[%d] kind %s has invalid param count %d", i, definition.Kind, len(definition.Params))
		}
		if definition.Presence != typedPresenceExplicit && definition.Presence != typedPresenceNonZero {
			return nil, fmt.Errorf("Input.Relations[%d].Presence %q is invalid", i, definition.Presence)
		}
		if definition.Stage != typedStageSourcePreRun && definition.Stage != typedStageAfterPrepare {
			return nil, fmt.Errorf("Input.Relations[%d].Stage %q is invalid", i, definition.Stage)
		}
		compiled := compiledRelation{kind: definition.Kind, presence: definition.Presence, stage: definition.Stage}
		local := make(map[string]struct{})
		for _, name := range definition.Params {
			field, ok := fieldByName[name]
			if !ok {
				return nil, fmt.Errorf("Input.Relations[%d] references unknown param --%s", i, name)
			}
			if _, duplicate := local[name]; duplicate {
				return nil, fmt.Errorf("Input.Relations[%d] repeats param --%s", i, name)
			}
			local[name] = struct{}{}
			compiled.fields = append(compiled.fields, field)
		}
		keyBytes, _ := json.Marshal(definition)
		key := string(keyBytes)
		if _, duplicate := seen[key]; duplicate {
			return nil, fmt.Errorf("Input.Relations[%d] duplicates an earlier relation", i)
		}
		seen[key] = struct{}{}
		result = append(result, compiled)
	}
	return result, nil
}

func compileAuthorization(definition typedAuthorizationDefinition, fields []compiledInputField, fieldByName map[string]int) error {
	for identity, authorization := range definition.Identities {
		for i, conditional := range authorization.ConditionalScopes {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Remove the duplicate entry from the relation's Params slice
  2. Deduplicate params programmatically before building the definition if they are assembled at runtime (in code, not a user flag)

Example fix

// before
Params: []string{"--message-id", "--message-id"}
// after
Params: []string{"--message-id"}
Defensive patterns

Strategy: validation

Validate before calling

seen := map[string]struct{}{}
for _, name := range rel.Params {
  if _, dup := seen[name]; dup { return fmt.Errorf("duplicate param %q", name) }
  seen[name] = struct{}{}
}

Try / catch

if err := common.CompileTypedDefinition(def); err != nil {
  return fmt.Errorf("relation param duplicate: %w", err)
}

Prevention

When it happens

Trigger: A Relation's Params slice contains the same flag name twice, e.g. Params: []string{"--chat_id", "--chat_id"}.

Common situations: Accidentally duplicating an entry while editing the params list; generating params programmatically and appending the same field twice; merging two param lists without dedup.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/dec5ea446565f3f7. Report an issue: GitHub.