iOfficeAI/OfficeCLI · error · FormatException
Expected base64(id),base64(target),0|1 entries separated by
Error message
Expected base64(id),base64(target),0|1 entries separated by '|'.
What it means
Thrown by DecodeDumpDrawingHyperlinks when an entry in the pipe-delimited dump-replay string does not match the exact 'base64(id),base64(target),0|1' shape. This is a round-trip format produced by the sibling EncodeDumpDrawingHyperlinks for replaying dumped drawing hyperlinks without a JSON serializer in the single-file executable. FormatException (not ArgumentException) signals corrupt/malformed transport data rather than bad user input.
Source
Thrown at src/officecli/Handlers/Excel/ExcelHandler.Helpers.Drawing.cs:513
{
static string B64(string value) => Convert.ToBase64String(
System.Text.Encoding.UTF8.GetBytes(value));
return string.Join("|", hyperlinks.Select(h =>
$"{B64(h.Id)},{B64(h.Target)},{(h.IsExternal ? "1" : "0")}"));
}
internal static List<DumpDrawingHyperlinkSpec> DecodeDumpDrawingHyperlinks(
string encoded)
{
static string FromB64(string value) => System.Text.Encoding.UTF8.GetString(
Convert.FromBase64String(value));
var result = new List<DumpDrawingHyperlinkSpec>();
if (string.IsNullOrEmpty(encoded)) return result;
foreach (var entry in encoded.Split('|', StringSplitOptions.RemoveEmptyEntries))
{
var fields = entry.Split(',');
if (fields.Length != 3 || (fields[2] != "0" && fields[2] != "1"))
throw new FormatException(
"Expected base64(id),base64(target),0|1 entries separated by '|'.");
result.Add(new DumpDrawingHyperlinkSpec
{
Id = FromB64(fields[0]),
Target = FromB64(fields[1]),
IsExternal = fields[2] == "1",
});
}
return result;
}
/// <summary>
/// Build the dump replay sequence for worksheet shapes without destroying
/// real DrawingML groups. A grouped TwoCellAnchor is carried verbatim when
/// every relationship referenced inside it is a hyperlink relationship;
/// those lightweight relationships can be recreated safely on replay.
///
/// Groups that reference package parts (pictures/charts/etc.) fall back toView on GitHub (pinned to 1ced45e900)
Solutions
- Regenerate the encoded string from EncodeDumpDrawingHyperlinks rather than authoring by hand.
- If you must author, ensure every entry is exactly b64(id),b64(target),0 or b64(id),b64(target),1, joined by '|'.
- Verify each id/target is standard base64 (A-Za-z0-9+/= only) so it cannot contain ',' or '|' and corrupt the split.
- Check for shell quoting issues: wrap the whole value in single quotes so '|' and ',' are not interpreted.
Example fix
// before
DecodeDumpDrawingHyperlinks("id,target,1")
// after
DecodeDumpDrawingHyperlinks(Convert.ToBase64String(UTF8.GetBytes("id")) + "," + Convert.ToBase64String(UTF8.GetBytes("target")) + ",1") Defensive patterns
Strategy: validation
Validate before calling
bool IsValidDumpHyperlinkEncoding(string encoded)
{
if (string.IsNullOrEmpty(encoded)) return true;
foreach (var entry in encoded.Split('|', StringSplitOptions.RemoveEmptyEntries))
{
var f = entry.Split(',');
if (f.Length != 3 || (f[2] != "0" && f[2] != "1")) return false;
try { Convert.FromBase64String(f[0]); Convert.FromBase64String(f[1]); }
catch { return false; }
}
return true;
} Type guard
static bool IsDumpHyperlinkEncoding(string s)
=> string.IsNullOrEmpty(s) || s.Split('|', StringSplitOptions.RemoveEmptyEntries)
.All(e => { var f = e.Split(','); return f.Length == 3 && (f[2]=="0"||f[2]=="1"); }); Try / catch
try { var links = DecodeDumpDrawingHyperlinks(encoded); }
catch (FormatException ex) when (ex.Message.Contains("base64(id),base64(target)"))
{
// the dump-replay stream is corrupt; regenerate via EncodeDumpDrawingHyperlinks
} Prevention
- Prefer regenerating the encoded string with EncodeDumpDrawingHyperlinks over hand-authoring.
- Keep base64 payloads intact (do not strip '=' padding).
- Shell-quote the whole value with single quotes so '|' and ',' survive.
- Validate field count and flag char before decoding if the string crossed an untrusted boundary.
When it happens
Trigger: Decoding a string where an entry has !=3 comma-fields, or where the third field is not literally '0' or '1'. Examples: 'aGQ=bmV3.doc,2' (wrong flag), 'id,target,1' (forgot base64), 'aGQ=' (only one field), or a hand-edited pipe string that lost a field. Also triggers if a base64 payload itself was split or trimmed of its '=' padding so the comma split yields the wrong count.
Common situations: Hand-editing a dumped drawing-hyperlink replay string; passing the output through a shell/pipe that interpreted ',' or '|' specially; mixing versions where the encode format changed; truncating the string in a log/copy-paste so the last entry is partial.
Related errors
- Property 'sqref' (or 'range'/'ref') is required for validati
- Invalid srcRect '{compound}'. Expected 'l=10,r=10,t=5,b=5' (
- Invalid crop '{cropAll}'. Expected four comma-separated perc
- gradientFill requires at least two '-' separated colors; got
- Picture/shape {key} is out of range for a oneCell/absolute d
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/f0410958f469b998.
Report an issue: GitHub.