{"record":{"id":"ff73193b61d80230","repo":"iOfficeAI/OfficeCLI","slug":"data-property-is-required-for-ole-base64-payloa","errorCode":null,"errorMessage":"'data' property is required for ole (base64 payload bytes)","messagePattern":"'data' property is required for ole \\(base64 payload bytes\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.cs","lineNumber":1278,"sourceCode":"                // but is all-in-one: Excel's OLE anatomy spans the worksheet\n                // (<oleObjects> child + embed/icon rels), the VML drawing\n                // (anchor shape) and <legacyDrawing>, all of which must stay\n                // consistent — so the handler wires everything here instead\n                // of leaving XML splicing to a companion raw-set.\n                // Props: rid + data (+content-type/extension) = payload part;\n                // icon-rid + icon-data (+icon-content-type) = objectPr image;\n                // vml-shape = the <v:shape> anchor XML verbatim;\n                // object-xml = the <oleObjects> CHILD element verbatim\n                // (mc:AlternateContent or bare oleObject, pinned rIds inside).\n                var oleSheetName = parentPartPath.TrimStart('/');\n                var oleWs = FindWorksheet(oleSheetName)\n                    ?? throw new ArgumentException(\n                        $\"Sheet not found: {oleSheetName}. ole must be added under a sheet: add-part <file> /<SheetName> --type ole\");\n                properties ??= new Dictionary<string, string>();\n                var oleRid = properties.GetValueOrDefault(\"rid\")\n                    ?? throw new ArgumentException(\"'rid' property is required for ole (pinned payload relationship id)\");\n                var oleDataB64 = properties.GetValueOrDefault(\"data\")\n                    ?? throw new ArgumentException(\"'data' property is required for ole (base64 payload bytes)\");\n                var oleObjectXml = properties.GetValueOrDefault(\"object-xml\")\n                    ?? throw new ArgumentException(\"'object-xml' property is required for ole (verbatim oleObjects child element)\");\n                byte[] oleBytes;\n                try { oleBytes = Convert.FromBase64String(oleDataB64); }\n                catch (FormatException) { throw new ArgumentException(\"add-part ole: 'data' is not valid base64\"); }\n\n                var oleCt = properties.GetValueOrDefault(\"content-type\")\n                    ?? \"application/vnd.openxmlformats-officedocument.oleObject\";\n                var oleExt = properties.GetValueOrDefault(\"extension\") ?? \".bin\";\n                if (!oleExt.StartsWith('.')) oleExt = \".\" + oleExt;\n\n                // Kind comes from the dump (source part type), because content\n                // type alone cannot classify legacy package formats (.xls\n                // carries application/vnd.ms-excel, not an OOXML CT). Fallback\n                // for hand-written batches that omit ole-kind: package iff the\n                // CT is a non-oleObject openxmlformats CT.\n                var oleKind = properties.GetValueOrDefault(\"ole-kind\")\n                    ?? (oleCt.StartsWith(","sourceCodeStart":1260,"sourceCodeEnd":1296,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.cs#L1260-L1296","documentation":"The 'data' property holds the base64-encoded OLE payload bytes (the .bin content of the embedded object). It is required because the handler writes these bytes into the new embedded object part. Without it there is no payload to store.","triggerScenarios":"AddPart(..., \"ole\", properties) where properties has no 'data' key or its value is null/empty.","commonSituations":"Hand-authored batch omitting the payload; a serialization layer stripping the large base64; targeting an OLE link (no payload) instead of an embedded object.","solutions":["Set properties[\"data\"] = Convert.ToBase64String(File.ReadAllBytes(...)) for the .bin payload.","Re-dump so the base64 payload is captured from the source embeddings part.","For linked OLE objects (no embedded payload), this carrier is the wrong tool."],"exampleFix":"// before\nvar props = new Dictionary<string,string>{ [\"rid\"]=\"rId4\", [\"object-xml\"]=objXml };\nhandler.AddPart(\"/Sheet1\", \"ole\", props);\n// after\nprops[\"data\"] = Convert.ToBase64String(\n    File.ReadAllBytes(\"/unpack/xl/embeddings/oleObject1.bin\"));\nhandler.AddPart(\"/Sheet1\", \"ole\", props);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(properties?.GetValueOrDefault(\"data\")))\n    throw new InvalidOperationException(\"ole requires base64 'data' payload.\");","typeGuard":"static bool HasData(Dictionary<string,string>? p) =>\n    !string.IsNullOrEmpty(p?.GetValueOrDefault(\"data\"));","tryCatchPattern":"try { handler.AddPart(parent, \"ole\", props); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"'data' property is required for ole\"))\n{ /* encode the .bin bytes, retry */ }","preventionTips":["Encode the embedded object bytes with Convert.ToBase64String.","For linked OLE (no payload), this carrier is the wrong tool.","Re-dump to capture the payload."],"tags":["excel","openxml","add-part","ole","required-property","base64"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}