{"record":{"id":"1b0b01eab43748a8","repo":"charmbracelet/gum","slug":"separator-must-be-single-character","errorCode":null,"errorMessage":"separator must be single character","messagePattern":"separator must be single character","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"table/command.go","lineNumber":45,"sourceCode":"\t\tinput, err = os.Open(o.File)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not render file: %w\", err)\n\t\t}\n\t} else {\n\t\tif stdin.IsEmpty() {\n\t\t\treturn fmt.Errorf(\"no data provided\")\n\t\t}\n\t\tinput = os.Stdin\n\t}\n\tdefer input.Close() //nolint: errcheck\n\n\ttransformer := unicode.BOMOverride(encoding.Nop.NewDecoder())\n\treader := csv.NewReader(transform.NewReader(input, transformer))\n\treader.LazyQuotes = o.LazyQuotes\n\treader.FieldsPerRecord = o.FieldsPerRecord\n\tseparatorRunes := []rune(o.Separator)\n\tif len(separatorRunes) != 1 {\n\t\treturn fmt.Errorf(\"separator must be single character\")\n\t}\n\treader.Comma = separatorRunes[0]\n\n\twriter := csv.NewWriter(os.Stdout)\n\twriter.Comma = separatorRunes[0]\n\n\tvar columnNames []string\n\tvar err error\n\t// If no columns are provided we'll use the first row of the CSV as the\n\t// column names.\n\tif len(o.Columns) <= 0 {\n\t\tcolumnNames, err = reader.Read()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to parse columns\")\n\t\t}\n\t} else {\n\t\tcolumnNames = o.Columns\n\t}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/table/command.go#L27-L63","documentation":"Gum table uses the --separator flag as the CSV field delimiter and validates it is exactly one rune. Passing an empty string or a multi-character string fails this check before parsing.","triggerScenarios":"`gum table -s ';'` is fine, but `gum table -s ''` (empty), `gum table -s '\\t'` (literal backslash-t, 2 chars), or `gum table -s ',,'` all trigger the error.","commonSituations":"Wanting a tab separator but passing the two-character literal '\\t' instead of a real tab; accidental whitespace in the flag value; passing multi-char sequences like '||'.","solutions":["Pass exactly one character: -s ';' or -s ','.","For tabs, use a real tab: -s $'\\t' (bash) or --separator \"$(printf '\\t')\".","Trim stray whitespace from the flag value.","For multi-character delimiters, preprocess the data (e.g. sed 's/||/,/g') before piping to gum table."],"exampleFix":"// before\ngum table -s '\\t' data.csv\n// after\ngum table -s $'\\t' < data.csv","handlingStrategy":"validation","validationCode":"sep=';'\nif [ ${#sep} -ne 1 ]; then echo \"separator must be 1 char\" >&2; exit 1; fi\ngum table -s \"$sep\" < data.csv","typeGuard":null,"tryCatchPattern":"if ! gum table -s \"$sep\" < data.csv 2>err.log; then echo \"bad separator: $(cat err.log)\" >&2; fi","preventionTips":["Count the separator length before passing it","Use $'\\t' for a literal tab, not the two-char string '\\t'","Preprocess multi-char delimiters with sed/awk before gum table"],"tags":["cli","csv","input-validation","argument-parsing"],"backgroundTag":"invalid-argument-value","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}