larksuite/cli · error
%s got both %q and %q, which are two names for the same flag
Error message
%s got both %q and %q, which are two names for the same flag, with different values — keep %q
What it means
When the input key is an alias for a vocab-known logical key and that logical key is already claimed by a different spelling with a different value, the dispatcher reports two names for the same flag carrying conflicting values and names the surviving spelling to keep.
Source
Thrown at shortcuts/sheets/batch_op_dispatch.go:490
// The alias AND its target are both present. This key is recognized,
// so it must not fall through to the generic "unknown input key"
// below — the claim() conflict message never fires here either,
// because keys are walked in sorted order and the alias can sort
// before its target ("size" < "width"), so nothing has claimed the
// logical key yet. Name both spellings and the survivor.
taken := target
if underscoreTaken {
taken = underscored
}
if jsonEqual(input[k], input[taken]) {
delete(input, k) // same value under two names: drop the alias.
// Hand the logical key over to the surviving spelling, or the
// claim recorded above would still point at the deleted alias
// and make that spelling's own turn read as a conflict.
canonical[target] = taken
continue
}
return fmt.Errorf("%s got both %q and %q, which are two names for the same flag, with different values — keep %q", sc, k, taken, taken) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error
}
if strings.ToLower(hv) == "ranges" && vocab["range"] && !vocab["ranges"] {
if _, taken := input["range"]; taken {
return fmt.Errorf("%s got both %q and \"range\" — keep \"range\" and drop %q", sc, k, k) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error
}
if arr, isArr := input[k].([]interface{}); isArr {
if len(arr) == 1 {
if s, isStr := arr[0].(string); isStr {
input["range"] = s
delete(input, k)
continue
}
}
return fmt.Errorf("%s takes a single \"range\" per sub-op, got %d entries in %q — split them into %d sub-ops (one per range)", sc, len(arr), k, len(arr)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error
}
if s, isStr := input[k].(string); isStr {
input["range"] = s
delete(input, k)View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Keep only the spelling named in the error (the `keep` value) and delete the other.
- Make both spellings carry the same value if repetition is accidental duplication from templating.
- Audit your op-building code for paths that can add the same logical flag twice.
Example fix
// before
{"field_key": "fldA", "fieldKey": "fldB"}
// after
{"field_key": "fldB"} Defensive patterns
Strategy: validation
Validate before calling
func assertSingleFlag(op map[string]interface{}, logical string, spellings ...string) error {
present := []string{}
for _, s := range spellings {
if _, ok := op[s]; ok { present = append(present, s) }
}
if len(present) > 1 {
return fmt.Errorf("flag %s set via %v; keep one", logical, present)
}
return nil
} Prevention
- Build ops through a single code path that writes each logical flag exactly once.
- Avoid template substitutions that can re-inject an existing field under different casing.
- Canonicalize flag names before constructing the op map.
When it happens
Trigger: A sub-op sets the same logical flag via two different spellings (e.g. `fieldKey` and `field_key`) with different values; the second spelling's turn hits the canonical claim recorded by the first.
Common situations: Scripted payloads that build the op conditionally and append the same field twice in different cases; template substitutions injecting a second copy of a flag under another casing.
Related errors
- %s got conflicting values for %q under two spellings (%q and
- %s got both %q and %q — keep %q and drop the other
- %s got both %q and "range" — keep "range" and drop %q
- Range needs a maximum column: {range_ref}
- Range needs a maximum row: {range_ref}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/7080443d49c0b7b4.
Report an issue: GitHub.