larksuite/cli · error

%s.Params contains duplicate param --%s

Error message

%s.Params contains duplicate param --%s

What it means

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.

Source

Thrown at shortcuts/common/typed_compile_contract.go:79

		for i, conditional := range authorization.ConditionalScopes {
			path := fmt.Sprintf("Authorization.%s.ConditionalScopes[%d]", identity, i)
			if len(conditional.Params) > 0 && conditional.When == "" {
				return fmt.Errorf("%s.Params requires agent-readable When text", path)
			}
			seen := make(map[string]struct{}, len(conditional.Params))
			for j, param := range conditional.Params {
				if param == "" || param != strings.TrimSpace(param) {
					return fmt.Errorf("%s.Params[%d] must be a non-blank trimmed param", path, j)
				}
				fieldIndex, ok := fieldByName[param]
				if !ok {
					return fmt.Errorf("%s references unknown param --%s", path, param)
				}
				if fields[fieldIndex].cli.Hidden {
					return fmt.Errorf("%s references hidden param --%s; use a public canonical param", path, param)
				}
				if _, duplicate := seen[param]; duplicate {
					return fmt.Errorf("%s.Params contains duplicate param --%s", path, param)
				}
				seen[param] = struct{}{}
			}
		}
	}
	return nil
}

func validateOutput(definition typedOutputDefinition, dataShape typedValueShape) error {
	switch definition.Mode {
	case typedOutputGeneric, typedOutputFixedJSON:
	default:
		return fmt.Errorf("Output.Mode %q is invalid", definition.Mode)
	}
	return nil
}

func decodeJSONPointerSegment(segment string) (string, bool) {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Remove the duplicate from the Params slice
  2. Deduplicate the slice before constructing the definition

Example fix

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

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

Trigger: ConditionalScopes entry with Params like []string{"--doc-id", "--doc-id"}.

Common situations: Duplicated entry during hand editing; merging param lists without dedup; generated slices appending an element twice.

Related errors


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