Skip to content

fix(sheets): correct Connected Sheets sheet identity and SYNC_ALL extract reads - #1001

Open
ryo-touch wants to merge 4 commits into
openclaw:mainfrom
ryo-touch:fix/connected-sheets-read-live-findings
Open

fix(sheets): correct Connected Sheets sheet identity and SYNC_ALL extract reads#1001
ryo-touch wants to merge 4 commits into
openclaw:mainfrom
ryo-touch:fix/connected-sheets-read-live-findings

Conversation

@ryo-touch

Copy link
Copy Markdown
Contributor

Refs #938

Live validation of the read-only Connected Sheets surface from #989, against a real set of
BigQuery-backed spreadsheets, surfaced two defects. Both are invisible to the current tests
because the fixture does not match what the API actually returns.

Summary

  • resolve a data source's linked sheet by data source id, and treat that sheet's own id as
    authoritative, so sheets datasource list stops reporting sheetId: 0
  • fall back to an unranged, properties-only fetch when a ranged spreadsheets.get cannot supply
    an extract's column count, which unblocks every SYNC_ALL extract
  • make the fixture server range-aware and drop dataSources[].sheetId from the fixture, so both
    paths are exercised the way the live API behaves

Details

datasource list always reported sheetId: 0. Live spreadsheets.get responses do not
populate Spreadsheet.dataSources[].sheetId; it comes back null. sheetsDataSourceToItem emitted
source.SheetId directly. The correct id is already available on the matched sheet, and
datasource table list uses it, so the two code paths now agree.

That same zero value also made findSheetsDataSourceSheet unsafe: it compared
properties.SheetId == source.SheetId before checking the data source id, so in a spreadsheet
containing a tab with sheet id 0, every data source would match that unrelated tab and report its
title and dataExecutionStatus. I could not reproduce this in practice — none of the 59
spreadsheets I scanned has a tab with sheet id 0 — so I am flagging it as latent rather than
observed. The ordering is wrong either way.

datasource table read failed for every SYNC_ALL extract. A SYNC_ALL table carries no
inline column list, so the column count has to come from dataSourceSheetProperties on the
associated DATA_SOURCE sheet. The anchor lookup passes ranges, and a ranged spreadsheets.get
returns only the sheets those ranges intersect, which excludes the DATA_SOURCE sheet:

ranges absent  -> grid sheets + DATA_SOURCE sheets
ranges present -> the anchor's grid sheet only

So dataSourceColumnCount found nothing and the command exited with
cannot determine columns for data-source table.

Proof

  • make ci
  • go test ./internal/cmd -run 'TestSheetsDataSource' -count=1 -v
  • both new assertions were confirmed to fail before their corresponding fix: the sheet-identity
    test reports the decoy tab, and the SYNC_ALL read test reproduces the exact
    cannot determine columns error

Live validation was read-only throughout (--readonly on every invocation; no spreadsheet was
modified):

before after
data sources resolving a real linked sheet id 0 / 56 56 / 56
extracts readable via datasource table read 0 / 54 54 / 54

Corpus: 59 spreadsheets scanned, 21 with Connected Sheets, 54 anchored extracts. Every extract in
it uses SYNC_ALL; there was not a single SELECTED extract, which is why this path failing was
total rather than partial.

Two notes:

  • the SYNC_ALL fallback costs a second spreadsheets.get on that path. Reading all 54 extracts
    back to back tripped Sheets rate limits a few times; pacing the loop cleared it. Worth knowing
    before scripting bulk extract reads.
  • docs/sheets-connected.md presents --extra-scopes .../bigquery.readonly --force-consent as a
    required step. It is not required when the stored token already carries a superset: all of the
    above ran on a token holding cloud-platform and spreadsheets, with no re-consent. That may
    be a cheaper route to a live Connected Sheets environment than provisioning the exact scopes.

ryo-touch and others added 2 commits August 17, 2026 14:10
…ce id

Live spreadsheets.get responses omit Spreadsheet.dataSources[].sheetId, so
`sheets datasource list` reported sheetId 0 for every data source, and the
sheet lookup could latch onto an unrelated tab whose sheet id happens to be 0
and report that tab's title and execution status instead.

Match the linked sheet on its data source id first, fall back to the sheet id
only when the API actually supplied one, and treat the resolved sheet's own id
as authoritative, mirroring what the extract listing already does.

The fixture hardcoded dataSources[].sheetId, which no live response carries;
drop it and add a decoy tab with sheet id 0 so the regression stays covered.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A ranged spreadsheets.get only returns the sheets its ranges intersect, so the
anchor lookup never carries the separate DATA_SOURCE sheet that holds a
SYNC_ALL table's column list. Every extract configured to sync all columns
failed with "cannot determine columns for data-source table".

Fall back to an unranged, properties-only fetch when the ranged response cannot
supply the column count.

The fixture server returned the whole spreadsheet regardless of ranges, and its
only extract used SELECTED columns, so neither half of this path was exercised.
Make the fixture server range-aware and add a SYNC_ALL extract.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added 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. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 1:47 AM ET / 05:47 UTC.

ClawSweeper review

What this changes

This PR resolves a Connected Sheet by data-source ID and fetches unscoped column metadata when a SYNC_ALL extract lacks inline columns.

Merge readiness

Ready for maintainer review

Keep open: current main still has both Connected Sheets read defects, while this focused PR supplies a source-aligned fix, regression coverage, and credible live after-fix validation. No blocking patch finding was identified.

Priority: P2
Reviewed head: 4d8b7d6467f659f6834a140c214db4c6bc9617ad

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong live validation and targeted regression coverage support a high-confidence, narrowly scoped repair.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body reports read-only, after-fix validation on 59 real spreadsheets: linked sheet IDs resolved for 56 of 56 sources and 54 of 54 SYNC_ALL extracts became readable.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports read-only, after-fix validation on 59 real spreadsheets: linked sheet IDs resolved for 56 of 56 sources and 54 of 54 SYNC_ALL extracts became readable.
Evidence reviewed 5 items Current-main defect: Current main emits the top-level data source's SheetId and matches that ID before its data-source ID; an omitted API field therefore has Go's zero value and can select an unrelated sheet 0.
SYNC_ALL failure path: Current main only obtains a column count from the range-scoped response and returns an error when that response omits the separate DATA_SOURCE sheet.
Focused implementation: The branch resolves the linked sheet by data-source ID first, treats its sheet ID as authoritative, and makes a narrow unscoped metadata request only when no column count is available.
Findings None None.
Security None None.

How this fits together

The Sheets CLI queries Google Sheets metadata to list Connected Sheets data sources and locate extract anchors before issuing a bounded values read. The linked data-source sheet supplies status and, for SYNC_ALL extracts, the column definitions needed to form that read.

flowchart LR
A[Sheets CLI command] --> B[Google Sheets metadata]
B --> C[Linked data-source sheet]
C --> D[Extract column count]
D --> E[Bounded values request]
E --> F[CLI JSON or table output]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus regression coverage production +41/-2, docs +2, tests/fixtures +215/-7 Most growth models the API’s real range behavior and protects both corrected paths.

Technical review

Best possible solution:

Land the scoped fix after required checks complete, retaining the additional metadata request only for extracts whose range-scoped response cannot provide columns.

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

Yes—current main visibly lacks the SYNC_ALL metadata fallback and uses the absent top-level sheet ID before data-source identity; the branch adds focused fixtures for both paths and reports live before/after validation.

Is this the best way to solve the issue?

Yes—the conditional, properties-only fallback preserves SELECTED extract behavior while obtaining the one missing metadata value for SYNC_ALL extracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eb85a99366eb.

Labels

Label justifications:

  • P2: The PR repairs a bounded Connected Sheets read/list defect with no evidence of an urgent broader outage.
  • 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. Sufficient (live_output): The PR body reports read-only, after-fix validation on 59 real spreadsheets: linked sheet IDs resolved for 56 of 56 sources and 54 of 54 SYNC_ALL extracts became readable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports read-only, after-fix validation on 59 real spreadsheets: linked sheet IDs resolved for 56 of 56 sources and 54 of 54 SYNC_ALL extracts became readable.

Evidence

What I checked:

  • Current-main defect: Current main emits the top-level data source's SheetId and matches that ID before its data-source ID; an omitted API field therefore has Go's zero value and can select an unrelated sheet 0. (internal/cmd/sheets_datasource.go:371, eb85a99366eb)
  • SYNC_ALL failure path: Current main only obtains a column count from the range-scoped response and returns an error when that response omits the separate DATA_SOURCE sheet. (internal/cmd/sheets_datasource.go:289, eb85a99366eb)
  • Focused implementation: The branch resolves the linked sheet by data-source ID first, treats its sheet ID as authoritative, and makes a narrow unscoped metadata request only when no column count is available. (internal/cmd/sheets_datasource.go:293, 4d8b7d6467f6)
  • Regression coverage: The branch makes the fixture range-aware, covers a decoy sheet 0 and missing top-level sheet IDs, and asserts one extra lookup for SYNC_ALL versus none for SELECTED extracts. (internal/cmd/sheets_datasource_test.go:135, 4d8b7d6467f6)
  • Feature provenance and ownership: Blame attributes the current read and sheet-resolution path to the released Connected Sheets implementation; repository context identifies its merged implementation PR as the feature origin. (internal/cmd/sheets_datasource.go:267, 45b5d766e137)

Likely related people:

  • steipete: Repository context identifies steipete as the author of the merged Connected Sheets read implementation, and current-path blame resolves to the release that contains it. (role: original feature author and likely follow-up owner; confidence: high; commits: a4c96debef00, 45b5d766e137; files: internal/cmd/sheets_datasource.go, internal/cmd/sheets_datasource_test.go, docs/sheets-connected.md)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-17T05:20:59.299Z sha ccc98ef :: needs maintainer review before merge. :: none

ryo-touch and others added 2 commits August 17, 2026 14:42
The unranged fallback added for SYNC_ALL extracts reused the full snapshot
field mask, which also pulls dataSources and dataSourceSchedules even though
only the data-source sheet column definitions are needed. Request just those
columns so the extra call stays small, and describe the call and its pacing
implications in the Connected Sheets guide.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add a direct table-driven test for findSheetsDataSourceSheet: the fixture no
longer supplies dataSources[].sheetId, so neither the data-source-id-first
ordering nor the sheet-id fallback was exercised through the command surface.

Assert how often the unranged column lookup fires — once for a SYNC_ALL
extract, never for a SELECTED one. Running it unconditionally would not just
cost a request; it would also overwrite a SELECTED table's own column count
and widen the read range.

Also stop calling t.Fatalf from the fixture server's handler goroutine, where
runtime.Goexit turns an assertion into a confusing handler abort, and drop a
redundant PathUnescape: net/http already decodes r.URL.Path, so re-decoding
would reject sheet names containing '%'.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant