{"record":{"id":"3716ec6981f7dedb","repo":"iOfficeAI/OfficeCLI","slug":"invalid-basetimeunit-value-expected-days-mon","errorCode":null,"errorMessage":"Invalid baseTimeUnit '{value}': expected days, months, or years.","messagePattern":"Invalid baseTimeUnit '(.+?)': expected days, months, or years\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Chart/ChartHelper.Axis.cs","lineNumber":560,"sourceCode":"                    }\n                    directlyHandled.Add(key);\n                    break;\n                }\n\n                case \"basetimeunit\":\n                {\n                    // Date-axis base time unit round-trip (days/months/years).\n                    if (targetAxis is C.DateAxis daxBtu)\n                    {\n                        var btuVal = value.Trim().ToLowerInvariant() switch\n                        {\n                            \"days\" or \"day\" => (C.TimeUnitValues?)C.TimeUnitValues.Days,\n                            \"months\" or \"month\" => C.TimeUnitValues.Months,\n                            \"years\" or \"year\" => C.TimeUnitValues.Years,\n                            _ => null,\n                        };\n                        if (btuVal == null)\n                            throw new ArgumentException($\"Invalid baseTimeUnit '{value}': expected days, months, or years.\");\n                        daxBtu.RemoveAllChildren<C.BaseTimeUnit>();\n                        var btuEl = new C.BaseTimeUnit { Val = btuVal.Value };\n                        // CT_DateAx: …auto?, lblOffset?, baseTimeUnit?, majorUnit?…\n                        var btuBefore = (OpenXmlElement?)daxBtu.GetFirstChild<C.MajorUnit>();\n                        if (btuBefore != null) daxBtu.InsertBefore(btuEl, btuBefore);\n                        else daxBtu.AppendChild(btuEl);\n                    }\n                    directlyHandled.Add(key);\n                    break;\n                }\n\n                case \"ticklabelpos\":\n                case \"ticklabelposition\":\n                {\n                    // CONSISTENCY(chart/axis-role-write): legacy SetChartProperties\n                    // tickLabelPos sweeps every ValueAxis + CategoryAxis. Role-scoped\n                    // write must only mutate the resolved axis. (R43-4)\n                    if (targetAxis is OpenXmlCompositeElement axTlp)","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Chart/ChartHelper.Axis.cs#L542-L578","documentation":"The baseTimeUnit setter applies to date axes (C.DateAxis) only. The value is trimmed and lowercased, then matched against days/months/years (with singular aliases day/month/year). Any other value sets btuVal to null and throws. The new C.BaseTimeUnit element is inserted in CT_DateAx schema order (before MajorUnit if present, else appended).","triggerScenarios":"Setting basetimeunit to an unrecognized value on a date axis: 'weeks', 'quarters', 'hours', 'seconds'. The target axis must be a C.DateAxis for this code path; other axis types skip it.","commonSituations":"Using 'weeks' or 'quarters' — OOXML ST_TimeUnit only supports days, months, years. Using 'h' or 'min' (time-based units not in the schema). Applying to a non-date axis (category or value axis) where it is silently ignored.","solutions":["Use days, months, or years (or singular day, month, year): basetimeunit=months.","For finer granularity than days, note that OOXML does not support it on date axes.","Ensure the target axis is a date axis (C.DateAxis) — this setting has no effect on category or value axes."],"exampleFix":"// before\nbasetimeunit=weeks\n// after\nbasetimeunit=days\n// or\nbasetimeunit=months","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> ValidBaseTimeUnits = new(StringComparer.OrdinalIgnoreCase)\n{ \"days\", \"day\", \"months\", \"month\", \"years\", \"year\" };\n\nstatic bool IsValidBaseTimeUnit(string value)\n    => ValidBaseTimeUnits.Contains(value.Trim());","typeGuard":null,"tryCatchPattern":"try { axisSetter.Apply(\"basetimeunit\", value); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid baseTimeUnit\"))\n{\n    Console.Error.WriteLine($\"{ex.Message}\\nValid: days, months, years.\");\n}","preventionTips":["Use only days, months, or years (singular forms also accepted).","OOXML date axes do not support weeks, quarters, hours, or minutes.","Ensure the target axis is a date axis (C.DateAxis) for this setting."],"tags":["chart","axis","date-axis","basetimeunit","invalid-value"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}