{"record":{"id":"bad5dfe9c69b8ae1","repo":"urfave/cli","slug":"item-q-is-missing-separator-q","errorCode":null,"errorMessage":"item %q is missing separator %q","messagePattern":"item %q is missing separator %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"flag_map_impl.go","lineNumber":82,"sourceCode":"\t}\n\n\tmvc := &i.multiValueConfig\n\tkeyValueSeparator := mvc.MapFlagKeyValueSeparator\n\tif len(keyValueSeparator) == 0 {\n\t\tkeyValueSeparator = defaultMapFlagKeyValueSeparator\n\t}\n\n\ttracef(\n\t\t\"splitting map value '%s', keyValueSeparator '%s', slice separator '%s', disable separator:%v\",\n\t\tvalue,\n\t\tkeyValueSeparator,\n\t\tmvc.SliceFlagSeparator,\n\t\tmvc.DisableSliceFlagSeparator,\n\t)\n\tfor _, item := range flagSplitMultiValues(value, mvc.SliceFlagSeparator, mvc.DisableSliceFlagSeparator) {\n\t\tkey, value, ok := strings.Cut(item, keyValueSeparator)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"item %q is missing separator %q\", item, keyValueSeparator)\n\t\t}\n\t\tif err := i.value.Set(value); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t(*i.dict)[key] = i.value.Get().(T)\n\t}\n\n\treturn nil\n}\n\n// String returns a readable representation of this value (for usage defaults)\nfunc (i *MapBase[T, C, VC]) String() string {\n\tv := i.Value()\n\tvar t T\n\tif reflect.TypeOf(t).Kind() == reflect.String {\n\t\treturn fmt.Sprintf(\"%v\", v)\n\t}\n\treturn fmt.Sprintf(\"%T{%s}\", v, i.ToString(v))","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/flag_map_impl.go#L64-L100","documentation":"For map flags (MapFlag), each value must be a key=value pair. Set splits the raw string into items (honoring the slice separator, default ','), then splits each item on the key/value separator (default '='). If an item contains no separator, it returns \"item %q is missing separator %q\".","triggerScenarios":"Passing a map flag value without '=' in one of the comma-separated items, e.g. `--opts foo` or `--opts a=1,b` (the item \"b\" has no '='), or an empty item like `--opts a=1,,b=2`.","commonSituations":"Users familiar with slice flags passing bare values to a map flag; shell quoting stripping the '=' or splitting items unexpectedly; copy-pasted config where the last pair lost its value (e.g. `a=1,b=` still works, but trailing `,b` does not).","solutions":["Ensure every comma-separated item is in key=value form, e.g. --opts a=1,b=2.","Quote the whole value in the shell so '=' and ',' survive: --opts \"a=1,b=2\".","Check SliceFlagSeparator configuration; if the separator was changed (or DisableSliceFlagSeparator set), items must be split on the configured separator.","Inspect the input for stray commas producing empty or malformed items and remove them."],"exampleFix":"// before\nmyapp --opts key1,key2=value\n\n// after\nmyapp --opts \"key1=value1,key2=value2\"","handlingStrategy":"validation","validationCode":"// shell: validate every comma-separated item contains '='\nvalue=\"key1=v1,key2=v2\"\nIFS=',' read -ra items <<< \"$value\"\nfor it in \"${items[@]}\"; do\n  [[ \"$it\" == *=* ]] || { echo \"bad map item (needs key=value): $it\" >&2; exit 1; }\ndone","typeGuard":"func validMapValue(v string, sep string) bool {\n    for _, item := range strings.Split(v, sep) {\n        if !strings.Contains(item, \"=\") { return false }\n    }\n    return true\n}","tryCatchPattern":"if err := cmd.Run(ctx, os.Args); err != nil {\n    if strings.Contains(err.Error(), \"is missing separator\") {\n        fmt.Fprintln(os.Stderr, \"map flags need key=value pairs, e.g. --opts a=1,b=2\")\n        os.Exit(2)\n    }\n    return err\n}","preventionTips":["Always write map flag values as comma-separated key=value pairs.","Quote the value in shells so ',' and '=' are preserved.","Remember empty items (double commas) are also invalid.","If you changed SliceFlagSeparator, update all callers to the new separator."],"tags":["cli","flags","parsing","map","go"],"backgroundTag":"malformed-key-value-pair","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}