iOfficeAI/OfficeCLI · error · ArgumentException
Invalid comboTypes token '{t}'. Expected bar/column/line/are
Error message
Invalid comboTypes token '{t}'. Expected bar/column/line/area/scatter, optionally with a stacked/percentstacked suffix (e.g. 'column,line' or 'columnstacked,line'). What it means
The comboTypes setter splits a comma-separated list of chart type tokens, strips optional 'stacked' or 'percentstacked' suffixes, and validates each base token against {bar, column, col, line, area, scatter}. Validation runs BEFORE any mutation to keep the rebuild atomic — unknown tokens used to silently fall through to the default LineChart arm, coercing garbage into line charts. Only the mini-language property that previously accepted typos.
Source
Thrown at src/officecli/Core/Chart/ChartHelper.Advanced.cs:517
/// </summary>
internal static void RebuildComboChart(C.Chart chart, string comboTypes)
{
var plotArea = chart.GetFirstChild<C.PlotArea>();
if (plotArea == null) return;
var typeList = comboTypes.Split(',').Select(t => t.Trim().ToLowerInvariant()).ToArray();
// Validate every token BEFORE any mutation: unknown tokens used to fall
// through to the default LineChart arm, silently coercing garbage
// (combotypes=asdf,qwer) into line,line — the only mini-language prop
// that accepted typos. Also keeps the rebuild atomic on bad input.
foreach (var t in typeList)
{
var baseToken = t.EndsWith("percentstacked", StringComparison.Ordinal) ? t[..^14]
: t.EndsWith("stacked", StringComparison.Ordinal) ? t[..^7]
: t;
if (baseToken is not ("bar" or "column" or "col" or "line" or "area" or "scatter"))
throw new ArgumentException(
$"Invalid comboTypes token '{t}'. Expected bar/column/line/area/scatter, " +
"optionally with a stacked/percentstacked suffix (e.g. 'column,line' or 'columnstacked,line').");
}
// Read all existing series data
var allSer = plotArea.Descendants<OpenXmlCompositeElement>()
.Where(e => e.LocalName == "ser").ToList();
if (allSer.Count == 0) return;
// Read series data
var seriesInfo = new List<(OpenXmlCompositeElement original, string targetType)>();
for (int i = 0; i < allSer.Count; i++)
{
var targetType = i < typeList.Length ? typeList[i] : typeList[^1];
seriesInfo.Add((allSer[i], targetType));
}
View on GitHub (pinned to 1ced45e900)
Solutions
- Use only bar, column (or col), line, area, or scatter as combo types: 'column,line'.
- Append 'stacked' or 'percentstacked' suffix for variants: 'columnstacked,line'.
- Do not use pie, doughnut, radar, stock, or bubble in comboTypes — they are not supported in combo charts.
Example fix
// before combotypes: "column,pie" // after combotypes: "column,line" // stacked variant combotypes: "columnstacked,line"
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> ValidComboBaseTokens = new()
{ "bar", "column", "col", "line", "area", "scatter" };
static bool AreComboTypesValid(string comboTypes)
{
foreach (var t in comboTypes.Split(',').Select(x => x.Trim().ToLowerInvariant()))
{
var baseToken = t.EndsWith("percentstacked", StringComparison.Ordinal) ? t[..^14]
: t.EndsWith("stacked", StringComparison.Ordinal) ? t[..^7]
: t;
if (!ValidComboBaseTokens.Contains(baseToken)) return false;
}
return true;
} Try / catch
try { ChartHelperAdvanced.ApplyComboTypes(plotArea, comboTypes); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Invalid comboTypes token"))
{
Console.Error.WriteLine($"{ex.Message}\nValid: bar, column, line, area, scatter (with optional stacked/percentstacked suffix).");
} Prevention
- Combo types only support bar, column, line, area, scatter — not pie, doughnut, or radar.
- Spell-check type tokens before passing them.
- Validate each token against the allowed set programmatically.
When it happens
Trigger: Passing a comboTypes value containing an unrecognized type token: 'column,asdf', 'pie,line', 'xyzstacked,bar'. The token (after suffix stripping) must be one of bar/column/col/line/area/scatter.
Common situations: Typing a chart type that is valid as a standalone chart but not as a combo member (e.g. 'pie' or 'doughnut' — combos only support bar/column/line/area/scatter). Misspelling 'column' as 'colunm' or 'colum'. Using 'colstacked' (valid) but with an unknown base like 'col2stacked'.
Related errors
- Unknown chart type: '{kind}'. Supported: column, bar, line,
- Invalid legend position '{posSpec}'. Valid: none, top, botto
- Invalid referenceLine value '{parts[0]}'. Expected: number o
- Invalid referenceLine width '{widthStr}'. Expected a number
- Invalid referenceLine width '{widthPt.ToString("G", System.G
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/5162a92e58957ec9.
Report an issue: GitHub.