iOfficeAI/OfficeCLI · error · ArgumentException
Invalid 'tickLabelPos' value: '{value}'. Valid: none, high,
Error message
Invalid 'tickLabelPos' value: '{value}'. Valid: none, high, low, nextTo. What it means
Thrown when 'tickLabelPos'/'tickLabelPosition' does not match any switch arm. OOXML ST_TickLblPos is {none, high, low, nextTo}; the setter also accepts 'top' (high) and 'bottom' (low) aliases. Any other token is rejected rather than silently defaulted.
Source
Thrown at src/officecli/Core/Chart/ChartHelper.Setter.cs:1869
var tickVal = ParseTickMark(value);
foreach (var ax in plotArea2.Elements<C.ValueAxis>().Where(a => !IsDeletedAxis(a)))
{ ax.RemoveAllChildren<C.MinorTickMark>(); InsertAxisChildInOrder(ax, new C.MinorTickMark { Val = tickVal }); }
foreach (var ax in plotArea2.Elements<C.CategoryAxis>().Where(a => !IsDeletedAxis(a)))
{ ax.RemoveAllChildren<C.MinorTickMark>(); InsertAxisChildInOrder(ax, new C.MinorTickMark { Val = tickVal }); }
break;
}
case "ticklabelpos" or "ticklabelposition":
{
var plotArea2 = chart.GetFirstChild<C.PlotArea>();
if (plotArea2 == null) { unsupported.Add(key); break; }
var tlPos = value.ToLowerInvariant() switch
{
"none" => C.TickLabelPositionValues.None,
"high" or "top" => C.TickLabelPositionValues.High,
"low" or "bottom" => C.TickLabelPositionValues.Low,
"nextto" => C.TickLabelPositionValues.NextTo,
_ => throw new ArgumentException($"Invalid 'tickLabelPos' value: '{value}'. Valid: none, high, low, nextTo.")
};
foreach (var ax in plotArea2.Elements<C.ValueAxis>().Where(a => !IsDeletedAxis(a)))
{ ax.RemoveAllChildren<C.TickLabelPosition>(); InsertAxisChildInOrder(ax, new C.TickLabelPosition { Val = tlPos }); }
foreach (var ax in plotArea2.Elements<C.CategoryAxis>().Where(a => !IsDeletedAxis(a)))
{ ax.RemoveAllChildren<C.TickLabelPosition>(); InsertAxisChildInOrder(ax, new C.TickLabelPosition { Val = tlPos }); }
break;
}
case "axisposition" or "axispos":
{
var plotArea2 = chart.GetFirstChild<C.PlotArea>();
if (plotArea2 == null) { unsupported.Add(key); break; }
var axPos = value.ToLowerInvariant() switch
{
"top" or "t" => C.AxisPositionValues.Top,
"bottom" or "b" => C.AxisPositionValues.Bottom,
"left" or "l" => C.AxisPositionValues.Left,
"right" or "r" => C.AxisPositionValues.Right,View on GitHub (pinned to 1ced45e900)
Solutions
- Use none, high (or top), low (or bottom), or nextTo.
- Trim and ToLowerInvariant user input before passing.
- Whitelist the value against the four schema values.
Example fix
// before
SetChartProperties(part, new() { ["tickLabelPos"] = "outside" });
// after
SetChartProperties(part, new() { ["tickLabelPos"] = "nextTo" }); Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> TickLabelPos =
new[]{"none","high","top","low","bottom","nextto"}, StringComparer.OrdinalIgnoreCase);
static bool IsValidTickLabelPos(string v) =>
!string.IsNullOrWhiteSpace(v) && TickLabelPos.Contains(v.Trim().ToLowerInvariant()); Type guard
static bool IsKnownTickLabelPos(string v) =>
(v?.Trim().ToLowerInvariant()) is "none" or "high" or "top" or "low" or "bottom" or "nextto"; Try / catch
try { SetChartProperties(part, props); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Invalid 'tickLabelPos'"))
{ /* default to nextTo and retry */ } Prevention
- Bind tick label position to the four schema values (none/high/low/nextTo).
- Do not reuse labelPos vocabulary for tick labels.
- Trim and lowercase free-text input.
When it happens
Trigger: SetChartProperties with { ["tickLabelPos"] = "middle" }, "outside", or a misspelled token.
Common situations: Generic 'outside'/'middle' vocabulary from another charting library; trailing whitespace or wrong case; copy from a config that used long-form 'nextTo' as 'next'.
Related errors
- axisMin={value} is invalid on a log-scaled axis: a logarithm
- Invalid majorUnit '{value}': must be a positive number (OOXM
- Invalid minorUnit '{value}': must be a positive number (OOXM
- Invalid 'axisPos' value: '{value}'. Valid: top, bottom, left
- Invalid 'crosses' value: '{value}'. Valid: autoZero, max, mi
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/412b42dfedaa26f2.
Report an issue: GitHub.