{"record":{"id":"700aa9edcec29468","repo":"iOfficeAI/OfficeCLI","slug":"drawing-group-hyperlinks-carrier-is-invalid-ex","errorCode":null,"errorMessage":"drawing-group 'hyperlinks' carrier is invalid: {ex.Message}","messagePattern":"drawing-group 'hyperlinks' carrier is invalid: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.cs","lineNumber":1150,"sourceCode":"                }\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\n                {\n                    groupHyperlinks = DecodeDumpDrawingHyperlinks(\n                        properties.GetValueOrDefault(\"hyperlinks\") ?? \"\");\n                }\n                catch (FormatException ex)\n                {\n                    throw new ArgumentException(\n                        $\"drawing-group 'hyperlinks' carrier is invalid: {ex.Message}\", ex);\n                }\n\n                Modified = true;\n                var groupDrawingsPart = groupWorksheet.DrawingsPart\n                    ?? groupWorksheet.AddNewPart<DrawingsPart>();\n                if (groupDrawingsPart.WorksheetDrawing == null)\n                {\n                    groupDrawingsPart.WorksheetDrawing = new XDR.WorksheetDrawing();\n                    groupDrawingsPart.WorksheetDrawing.Save();\n                }\n                var groupSheet = GetSheet(groupWorksheet);\n                if (groupSheet.GetFirstChild<SpreadsheetDrawing>() == null)\n                {\n                    var drawingRelId = groupWorksheet.GetIdOfPart(groupDrawingsPart);\n                    groupSheet.Append(new SpreadsheetDrawing { Id = drawingRelId });\n                    SaveWorksheet(groupWorksheet);\n                }","sourceCodeStart":1132,"sourceCodeEnd":1168,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.cs#L1132-L1168","documentation":"DecodeDumpDrawingHyperlinks threw a FormatException while parsing the compact 'hyperlinks' property. The carrier format is `base64(id),base64(target),0|1` entries joined by '|'. It throws when an entry does not split into exactly three comma-separated fields, the third field is not '0'/'1', or a base64 segment fails to decode. The original FormatException message is embedded.","triggerScenarios":"The hyperlinks string is hand-edited, contains extra commas inside a base64 segment (base64 itself never does, so this implies tampering), uses a different delimiter, has a stray '|', or one segment's base64 is corrupted.","commonSituations":"Manually constructing the carrier instead of using EncodeDumpDrawingHyperlinks; a search/replace that altered delimiters; truncation mid-entry; an empty entry that still has a stray comma.","solutions":["Build the carrier with EncodeDumpDrawingHyperlinks rather than by hand, so field count and base64 are guaranteed.","If editing manually, keep to exactly base64(id),base64(target),0|1 joined by '|' with no empty entries.","Omit the 'hyperlinks' key entirely when there are no hyperlinks (empty string is accepted and yields no entries).","Round-trip a known-good carrier through Decode in a test to spot the offending entry."],"exampleFix":"// before — hand-rolled, wrong delimiter / field count\nprops[\"hyperlinks\"] = \"rId1;https://x.com;1\";\n// after — use the encoder\nprops[\"hyperlinks\"] = EncodeDumpDrawingHyperlinks(new[]{\n    new DumpDrawingHyperlinkSpec { Id=\"rId1\", Target=\"https://x.com\", IsExternal=true }});","handlingStrategy":"try-catch","validationCode":"try { DecodeDumpDrawingHyperlinks(props.GetValueOrDefault(\"hyperlinks\") ?? \"\"); }\ncatch (FormatException ex) { /* carrier malformed — rebuild with Encode */ }","typeGuard":"static bool HyperlinksCarrierOk(string encoded)\n{ try { DecodeDumpDrawingHyperlinks(encoded); return true; } catch { return false; } }","tryCatchPattern":"try { handler.AddPart(parent, \"drawing-group\", props); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"'hyperlinks' carrier is invalid\"))\n{ /* rebuild with EncodeDumpDrawingHyperlinks, then retry */ }","preventionTips":["Always build the carrier with EncodeDumpDrawingHyperlinks, never by hand.","Omit the hyperlinks key entirely when there are none.","Keep entries to exactly base64(id),base64(target),0|1 joined by '|'."],"tags":["excel","openxml","add-part","drawing-group","hyperlinks","serialization"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}