Skip to content

fix(drive): print [] instead of null for empty label and comment lists - #1326

Closed
saariuslystoned wants to merge 2 commits into
openclaw:mainfrom
saariuslystoned:fix/empty-lists-json-arrays
Closed

saariuslystoned wants to merge 2 commits into
openclaw:mainfrom
saariuslystoned:fix/empty-lists-json-arrays

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Google omits empty list fields from responses. drive labels list, drive labels file list, drive comments list and docs comments list passed the missing field straight through, so with --json they printed "labels": null or "comments": null when there was nothing to list. With --results-only they printed null instead of []. sheets notes and sheets links had the same issue (#1314).

Fix

  • A small generic nonNilSlice helper returns [] for a nil slice.
  • Both labels outputs use it, and so does the return of listDriveComments, which both comments commands share.
  • Non-empty output and table output are unchanged.

Tests

internal/cmd/empty_list_json_test.go runs each command through the CLI against an httptest server that returns {}, as the API does for an empty list. It checks --json (list key is []) and --json --results-only (prints []).

  • On main (e8428c3), all four fail with null.

  • With this change, all four pass. The existing labels and comments tests also pass.

  • Built gog binaries from main and from this branch were run against a local stand-in through GOG_GOOGLE_API_BASE_URL. The stand-in is not Google: it answers each list with {}, as Google does for an empty list.

    $ gog --json drive labels list                  main: "labels": null     branch: "labels": []
    $ gog --json --results-only drive labels list   main: null               branch: []
    $ gog --json drive labels file list file1       main: "labels": null     branch: "labels": []
    $ gog --json drive comments list doc1           main: "comments": null   branch: "comments": []
    $ gog --json docs comments list doc1            main: "comments": null   branch: "comments": []
    

Every make ci step passed on 1bc548a (go1.27.3); the head 6653159 only adds this PR's number to the CHANGELOG entry. The Go test suite ran on a second macOS arm64 machine, and the fmt, lint, deadcode, docs, agent-skills and node checks ran locally.

@saariuslystoned

☁️

🤖 Generated with Claude Code

saariuslystoned and others added 2 commits November 9, 2026 11:01
Google omits empty list fields, so drive labels list, drive labels file list, drive comments list and docs comments list printed null with --json (and --results-only) when there was nothing to list. Return an empty slice instead.

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

clawsweeper Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Empty Drive label and Drive/Docs comment lists serialize as [] in JSON output.

Example: Run gog --json drive labels file list file1 when file1 has no labels.

  • Before: The labels field is null.
  • After: The labels field is [], and --results-only returns [].

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, useful bug fix with shipped-command evidence, meaningful regressions, and no actionable findings; CI success is contributor-reported rather than independently rerun.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Updated terminal output shows built main and branch binaries exercising all four affected commands against a local {} API response through the shipped transport, with arrays after the fix and results-only behavior demonstrated; no live Google account is claimed or needed for this serialization change.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Scripts expecting arrays receive null when label or comment lists are empty.
Reason: The change restores the established empty-list JSON convention without adding options or changing requests.

Merge readiness

✅ Ready for maintainer review

This PR fixes an empty-list JSON bug still present on main; source review found no actionable defect, and the updated built-CLI evidence clears the earlier proof request.

Priority: P2
Reviewed head: 6653159593742f58ec52d09e405807de6c25d9e6

Before merge

None.

Findings

None.

Agent review details

How this fits together

Drive and Docs list commands receive Google API responses, collect labels or comments, and pass their results through the shared JSON formatter.

flowchart LR
 CLI[CLI list command] --> API[Google API client]
 API --> Response[List response]
 Response --> Normalize[Normalize empty slice]
 Normalize --> JSON[JSON formatter]
 JSON --> Output[JSON envelope or results array]
Loading

Technical review

Best possible solution:

Land the focused normalization fix with its command regressions and Unreleased changelog entry.

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

Main's nil-slice paths explain the reported null output, and the contributor supplies command regressions plus built-binary before/after output; this review did not execute target code.

Is this the best way to solve the issue?

Normalization preserves non-empty values, pagination, error propagation, and text output while fixing the shared comment owner and both label outputs.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Drive label JSON lists keeps the original intent (d949466: The read-only label surface and later file-label expansion exposed API list fields directly; available history establishes no intentional null-output contract.)
  • Shared Drive/Docs comment listing keeps the original intent (c38a701: The recorded change shares Drive-backed comment operations; normalization preserves that ownership, filtering, and pagination. Older blob inspection was limited by missing promisor objects.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c38a701 adds internal/cmd/comment_ops.go:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c38a701c3baf; files: internal/cmd/comment_ops.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: Empty-list JSON output breaks array-consuming scripts on a limited set of list commands.
  • 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-09T16:12:10.260Z sha 6653159 :: needs real behavior proof before merge. :: none

Reviewed November 9, 2026, 11:33 AM ET / 16:33 UTC (Revision 2).

@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 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. clawsweeper:intake:needs-environment 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
steipete added a commit that referenced this pull request Nov 14, 2026
Consolidate reproduced command bugs from #1308, #1311-#1319, #1321-#1326 and issues #1328, #1329, #1330, #1331, #1335.

Co-authored-by: Bobby Bones <159389674+saariuslystoned@users.noreply.github.com>
Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
@steipete

Copy link
Copy Markdown
Collaborator

Thank you for the fix. I reproduced the claim and consolidated emitting empty Drive label and Drive/Docs comment lists as arrays 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