{"record":{"id":"4fb885a92baeb024","repo":"iOfficeAI/OfficeCLI","slug":"anchor-xml-property-is-required-for-drawing-grou","errorCode":null,"errorMessage":"'anchor-xml' property is required for drawing-group (verbatim xdr anchor XML)","messagePattern":"'anchor-xml' property is required for drawing-group \\(verbatim xdr anchor XML\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.cs","lineNumber":1125,"sourceCode":"                var chartIdx = drawingsPart.ChartParts.ToList().IndexOf(chartPart);\n                return (relId, $\"/{sheetName}/chart[{chartIdx + 1}]\");\n\n            case \"drawing-group\":\n            {\n                // Verbatim DrawingML group carrier for xlsx dump→batch.\n                // The full hosting anchor is preserved because flattening a\n                // <xdr:grpSp> loses the child coordinate system, z-order,\n                // styles and the fact that the objects are grouped. Only\n                // hyperlink relationships are carried here; dump falls back\n                // to semantic leaf shapes when a group references package\n                // parts such as images/charts.\n                var groupSheetName = parentPartPath.TrimStart('/');\n                var groupWorksheet = FindWorksheet(groupSheetName)\n                    ?? throw new ArgumentException(\n                        $\"Sheet not found: {groupSheetName}. drawing-group must be added under a sheet.\");\n                properties ??= new Dictionary<string, string>();\n                var anchorXml = properties.GetValueOrDefault(\"anchor-xml\")\n                    ?? throw new ArgumentException(\n                        \"'anchor-xml' property is required for drawing-group (verbatim xdr anchor XML)\");\n\n                XDR.TwoCellAnchor groupAnchor;\n                try\n                {\n                    groupAnchor = new XDR.TwoCellAnchor(anchorXml);\n                }\n                catch (Exception ex)\n                {\n                    throw new ArgumentException(\n                        $\"drawing-group anchor XML is not a valid xdr:twoCellAnchor: {ex.Message}\", ex);\n                }\n                if (groupAnchor.GetFirstChild<XDR.GroupShape>() == null)\n                    throw new ArgumentException(\n                        \"drawing-group anchor XML must contain a top-level xdr:grpSp.\");\n\n                List<DumpDrawingHyperlinkSpec> groupHyperlinks;\n                try","sourceCodeStart":1107,"sourceCodeEnd":1143,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.cs#L1107-L1143","documentation":"The drawing-group carrier requires the full <xdr:twoCellAnchor> markup that hosts the group, supplied as the 'anchor-xml' property. Because grouped shapes have no semantic add vocabulary, the entire anchor (with its child coordinate system, z-order, and styles) is carried verbatim. A null/missing 'anchor-xml' key leaves the handler with nothing to append.","triggerScenarios":"AddPart(...) called with a properties dictionary that has no 'anchor-xml' key, or whose value is null/empty. Typical of a hand-written batch or a dump→batch serialization that dropped the field.","commonSituations":"Manually authoring an add-part batch and omitting anchor-xml; a JSON/cell transport layer that stripped the long XML string; re-using a picture/shape property bag that never had anchor-xml.","solutions":["Add properties[\"anchor-xml\"] with the complete <xdr:twoCellAnchor>...</xdr:twoCellAnchor> markup.","Re-dump the source workbook so the anchor-xml is regenerated from the real group.","If authoring by hand, copy the anchor XML from the source xlsx's xl/drawings/drawingN.xml."],"exampleFix":"// before\nvar props = new Dictionary<string,string> { [\"hyperlinks\"] = \"\" };\nhandler.AddPart(\"/Sheet1\", \"drawing-group\", props);\n// after\nprops[\"anchor-xml\"] = \"<xdr:twoCellAnchor xmlns:xdr=\\\"...\\\">...<xdr:grpSp>...</xdr:grpSp></xdr:twoCellAnchor>\";\nhandler.AddPart(\"/Sheet1\", \"drawing-group\", props);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(properties?.GetValueOrDefault(\"anchor-xml\")))\n    throw new InvalidOperationException(\"anchor-xml missing — supply the verbatim twoCellAnchor XML.\");","typeGuard":"static bool HasAnchorXml(Dictionary<string,string>? p) =>\n    !string.IsNullOrEmpty(p?.GetValueOrDefault(\"anchor-xml\"));","tryCatchPattern":"try { handler.AddPart(parent, \"drawing-group\", props); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"'anchor-xml' property is required\"))\n{ /* populate props[\"anchor-xml\"] then retry */ }","preventionTips":["Treat anchor-xml as mandatory in any batch authoring helper.","Re-dump to regenerate the anchor XML rather than hand-writing it.","Unit-test batch builders to reject missing anchor-xml before submission."],"tags":["excel","openxml","add-part","drawing-group","required-property"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}