Skip to content

fix(sheets): keep each sheet row on one line in text output - #1316

Closed
saariuslystoned wants to merge 3 commits into
openclaw:mainfrom
saariuslystoned:fix/sheets-get-one-line-cells
Closed

saariuslystoned wants to merge 3 commits into
openclaw:mainfrom
saariuslystoned:fix/sheets-get-one-line-cells

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

docs/automation.md describes --plain as stable TSV. gog sheets get writes each cell with fmt.Sprintf("%v", cell) and joins cells with tabs, so a cell that contains a line break or a tab breaks the row. Multi-line cells are common in Sheets: an address, notes, and anything entered with Ctrl+Enter.

$ gog --plain sheets get <id> 'Sheet1!A1:C2'
Name	Address	Note
Alice	1 Main St
Berlin	a	b

The one data row comes out as two lines. The second line looks like a row starting with Berlin, and the tab inside a<TAB>b adds a column. sheets datasource table read builds its rows the same way.

The other Sheets cell tables already avoid this. sheets links, sheets notes, sheets format and sheets validation pass their values through oneLine (internal/cmd/sheets_presentation.go), which writes a line break as \n and a tab as a space. calendar events --location collapses multi-line addresses for the same reason.

Change

sheets get and sheets datasource table read now share a small sheetsValueRowLine helper. It passes each cell through the existing oneLine before joining, so each sheet row stays one output line with one column per cell:

Name	Address	Note
Alice	1 Main St\nBerlin	a b

This applies to text and --plain output. JSON output is unchanged and still the lossless form. Cells without line breaks or tabs print exactly as before.

Evidence

  • TestSheetsGetCmd_PlainKeepsMultilineCellsOnOneRow runs gog --plain sheets get through the CLI entry point against an httptest Sheets server that returns a cell with \n and one with \t. It fails on main (e8428c3) with the split row shown above, and passes with this change. The same test also covers a \r\n cell, a number and a boolean. The existing TestSheetsGetCmd_PlainOutputTSV and the rest of the Sheets tests pass.

  • Built gog binaries from main and from this branch were run against a local Sheets stand-in through GOG_GOOGLE_API_BASE_URL (not Google). values.get returns Alice | 1 Main St\nBerlin | a\tb and Bob | 2 High St\r\nParis | ok; spreadsheets.get returns the repo's Connected Sheets fixture. Each stdout line is shown as a Python repr:

    main   --plain sheets get s1 'Sheet1!A1:C3'                    and   --plain sheets datasource table read connected1 Extracts!B3
    'Name\tAddress\tNote'
    'Alice\t1 Main St'
    'Berlin\ta\tb'                 <- row split, extra column
    'Bob\t2 High St\r'
    'Paris\tok'
    
    branch (both commands, identical)
    'Name\tAddress\tNote'
    'Alice\t1 Main St\\nBerlin\ta b'
    'Bob\t2 High St\\nParis\tok'
    

    The aligned text mode (no --plain) splits the same way on main and stays on one line per row on the branch. --json --results-only sheets get prints the same value on both: [["Name","Address","Note"],["Alice","1 Main St\nBerlin","a\tb"],["Bob","2 High St\r\nParis","ok"]].

  • Every make ci step passed on 6a3b0c5 (go1.27.3). The Go test suite (go test -count=1 ./...) ran on a second macOS arm64 machine, and the fmt, lint, deadcode, docs, agent-skills and node checks ran locally.

This changes local formatting only. The request to Google is unchanged, and no live spreadsheet was used. Anyone who relied on raw line breaks in text output will now see \n; --json keeps the original value.

🤖 Generated with Claude Code

sheets get and sheets datasource table read joined raw cell values with
tabs, so a cell with a line break or tab split its row in text and
--plain output. Escape cells with the existing oneLine helper, as the
links, notes, format and validation tables already do. JSON output is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR escapes cell line breaks and replaces embedded tabs with spaces in both Sheets value readers’ text and TSV output.

Example: Alice’s row contains address "1 Main St\nBerlin" and note "a\tb".

  • Before: The address creates an extra output line and the note creates an extra column.
  • After: The address prints a literal \n and the note prints "a b", preserving one output row and three columns.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with shipped-CLI evidence, command-path regression coverage, resolved earlier feedback, and no remaining findings; full CI completion is not established by the dispatch checks.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Captured built-gog output exercises sheets get and sheets datasource table read through the existing API-base-URL transport against a local Sheets stand-in, showing corrected newline, CRLF, and tab rendering; the body also reports aligned-text behavior and supplies unchanged JSON output.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A single Sheets record appears as multiple rows or extra columns when a cell contains a line break or tab.
Reason: The change restores documented stable TSV using an existing formatting convention and preserves original values in JSON.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current Sheets output bug with a focused shared formatter; the previous finding and proof requests are resolved, and no actionable defects remain.

Priority: P2
Reviewed head: 6a3b0c505fef573c23baf857d75ed5a952815496

Before merge

None.

Findings

None.

Agent review details

How this fits together

Sheets CLI commands receive cell arrays from Google’s API and render JSON, aligned text, or TSV; this change affects only text and TSV rendering.

flowchart LR
 A[Sheets CLI commands] --> B[Google Sheets API]
 B --> C[Cell arrays]
 C --> D[Unchanged JSON output]
 C --> E[Shared value row formatter]
 E --> F[Existing oneLine helper]
 F --> G[Text or TSV output]
Loading

Technical review

Best possible solution:

Use the existing oneLine convention in one shared value-row formatter while retaining separator tabs and lossless JSON.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly demonstrates delimiter leakage, and the contributor supplies failing-base and passing-branch CLI output for newline, CRLF, and tab-containing cells.

Is this the best way to solve the issue?

The shared formatter is a small complete repair for the reported inputs and follows established Sheets formatting behavior without adding another escaping policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e8428c36dd31.

Provenance checked

  • Sheets value text and TSV rendering keeps the original intent (6228856: Preserve actual column-separator tabs in plain output instead of expanding them through tabwriter.)
  • Connected Sheets value rendering keeps the original intent (feat(sheets): add Connected Sheets reads #989: Provide bounded read-only extract reads with explicit authorization and anchor-cell identity.)
  • Unreleased changelog keeps the original intent (chore(release): open 0.48.1 development cycle #1307: Open the next development section while retaining finalized release notes.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still contains the defect: Both value readers stringify cells without sanitizing embedded row or column delimiters; main remains at the pinned base revision. (internal/cmd/sheets.go:169, e8428c36dd31)
  • Small shared repair: The introduced diff replaces both duplicate formatting loops with sheetsValueRowLine, using existing oneLine behavior; requests and JSON branches remain unchanged. (internal/cmd/sheets.go:177, 6a3b0c505fef)
  • Existing output contract: Automation documentation promises stable TSV; oneLine already normalizes CRLF and CR, replaces embedded tabs with spaces, and renders newlines as literal escape sequences, including in existing Sheets presentation tables. (internal/cmd/output_helpers.go:69, e8428c36dd31)
  • Previous review work resolved: Compared with the earlier reviewed head, the changelog now includes the required reference and thanks, and the helper-only test is removed with CRLF and scalar cases moved into command-path coverage. (internal/cmd/sheets_plain_test.go:86, 6a3b0c505fef)
  • Shipped CLI behavior evidence: The complete PR body supplies captured before-and-after built-binary output for both changed commands against a local Sheets server through GOG_GOOGLE_API_BASE_URL, reports aligned-text results, and shows unchanged JSON values; the discussion adds no contrary evidence. (6a3b0c505fef)
  • Feature history and prior intent: Commit 6228856 preserves separator tabs through tableWriter; fix(sheets): respect --plain flag for TSV output in metadata command #298 adds TSV command coverage, and feat(sheets): add Connected Sheets reads #989 introduces bounded Connected Sheets reads. These are complementary changes rather than fixes for embedded cell delimiters. (internal/cmd/sheets.go:166, 6228856668c0)

Likely related people:

  • Peter Steinberger: Raw commit 6228856 adds internal/cmd/sheets.go:121 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6228856668c0; files: internal/cmd/sheets.go)
  • Mahsum Aktaş: Raw commit b6c5c79 adds internal/cmd/sheets_plain_test.go:32 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: b6c5c79d42e1; files: internal/cmd/sheets_plain_test.go)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Embedded cell delimiters break Sheets text and TSV consumers, while JSON provides a lossless alternative.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-08T14:55:30.214Z sha 420db38 :: needs real behavior proof before merge. :: [P3] [P3] Add the required reference to the changelog entry

Reviewed November 8, 2026, 3:11 PM ET / 20:11 UTC (Revision 2).

saariuslystoned and others added 2 commits November 8, 2026 14:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the helper-only cases into the command-path test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 8, 2026
@steipete

Copy link
Copy Markdown
Collaborator

Thank you for the fix. I reproduced the claim and consolidated keeping multiline Sheets cells on a single text-output row into #1336, with regression coverage and your coauthor credit retained. The full make ci gate, built-CLI checks for the new request-validation fixes, and exact-head GitHub CI passed. Closing this PR as superseded by the merged implementation in #1336.

@steipete steipete closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants