Skip to content

docs write --append --markdown: empty-header tables leak last row as literal pipe text after the table #609

@chrischall

Description

@chrischall

Summary

When gog docs write --append --markdown is given a markdown table with an empty header row (two columns, blank header cells), the table is rendered correctly for all rows EXCEPT the last data row, which is duplicated as a literal | cell | cell | paragraph after the table.

Reported by my AI agent (Claude Code) while building MCP coverage on top of gogcli.

Repro

cat > /tmp/repro.md <<'MD'
|     |     |
|-----|-----|
| Label A | Value A |
| Label B | Value B |
MD

DOC=$(gog docs create "MD empty-header repro" --json | jq -r '.file.id')
gog docs write "$DOC" --append --markdown --file=/tmp/repro.md
gog docs cat "$DOC" --json | jq -r '.text'

Expected

A 2-column, 3-row table (blank header + 2 data rows), or a 2-row table if blank headers are dropped.

Actual

Label A	Value A
Label B	Value B
| Label B | Value B |        ← literal pipe text duplicated after the table

The first data row is in the table, the second data row is in the table AND also appears as a literal text paragraph after it.

Build

v0.17.0 (aee7460 2026-05-15T18:10:07Z) (macOS, Homebrew install)

Notes

  • Tables with non-empty headers render correctly with all rows in the table.
  • Off-by-one in the row-count or row-loop when header is empty? Looks like the parser computes N rows for the table grid but actually inserts N-1, leaving the last row to fall through to the text path.

Workaround

Always supply a non-empty header row, e.g.:

| Label | Value |
|-------|-------|
| Label A | Value A |
| Label B | Value B |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions