{"record":{"id":"7080443d49c0b7b4","repo":"larksuite/cli","slug":"s-got-both-q-and-q-which-are-two-names-for-the","errorCode":null,"errorMessage":"%s got both %q and %q, which are two names for the same flag, with different values — keep %q","messagePattern":"(.+?) got both %q and %q, which are two names for the same flag, with different values — keep %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/batch_op_dispatch.go","lineNumber":490,"sourceCode":"\t\t\t// The alias AND its target are both present. This key is recognized,\n\t\t\t// so it must not fall through to the generic \"unknown input key\"\n\t\t\t// below — the claim() conflict message never fires here either,\n\t\t\t// because keys are walked in sorted order and the alias can sort\n\t\t\t// before its target (\"size\" < \"width\"), so nothing has claimed the\n\t\t\t// logical key yet. Name both spellings and the survivor.\n\t\t\ttaken := target\n\t\t\tif underscoreTaken {\n\t\t\t\ttaken = underscored\n\t\t\t}\n\t\t\tif jsonEqual(input[k], input[taken]) {\n\t\t\t\tdelete(input, k) // same value under two names: drop the alias.\n\t\t\t\t// Hand the logical key over to the surviving spelling, or the\n\t\t\t\t// claim recorded above would still point at the deleted alias\n\t\t\t\t// and make that spelling's own turn read as a conflict.\n\t\t\t\tcanonical[target] = taken\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn 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\n\t\t}\n\t\tif strings.ToLower(hv) == \"ranges\" && vocab[\"range\"] && !vocab[\"ranges\"] {\n\t\t\tif _, taken := input[\"range\"]; taken {\n\t\t\t\treturn 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\n\t\t\t}\n\t\t\tif arr, isArr := input[k].([]interface{}); isArr {\n\t\t\t\tif len(arr) == 1 {\n\t\t\t\t\tif s, isStr := arr[0].(string); isStr {\n\t\t\t\t\t\tinput[\"range\"] = s\n\t\t\t\t\t\tdelete(input, k)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn 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\n\t\t\t}\n\t\t\tif s, isStr := input[k].(string); isStr {\n\t\t\t\tinput[\"range\"] = s\n\t\t\t\tdelete(input, k)","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/batch_op_dispatch.go#L472-L508","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"field_key\": \"fldA\", \"fieldKey\": \"fldB\"}\n// after\n{\"field_key\": \"fldB\"}","handlingStrategy":"validation","validationCode":"func assertSingleFlag(op map[string]interface{}, logical string, spellings ...string) error {\n    present := []string{}\n    for _, s := range spellings {\n        if _, ok := op[s]; ok { present = append(present, s) }\n    }\n    if len(present) > 1 {\n        return fmt.Errorf(\"flag %s set via %v; keep one\", logical, present)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["sheets","validation","naming-convention"],"backgroundTag":"conflicting-parameter-spelling","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"}