Repository navigation
fix(drive): print [] instead of null for empty label and comment lists - #1326
saariuslystoned wants to merge 2 commits into
Conversation
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>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesEmpty 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDrive 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 11:33 AM ET / 16:33 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
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 |
Problem
Google omits empty list fields from responses.
drive labels list,drive labels file list,drive comments listanddocs comments listpassed the missing field straight through, so with--jsonthey printed"labels": nullor"comments": nullwhen there was nothing to list. With--results-onlythey printednullinstead of[].sheets notesandsheets linkshad the same issue (#1314).Fix
nonNilSlicehelper returns[]for a nil slice.listDriveComments, which both comments commands share.Tests
internal/cmd/empty_list_json_test.goruns each command through the CLI against anhttptestserver 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 withnull.With this change, all four pass. The existing labels and comments tests also pass.
Built
gogbinaries frommainand from this branch were run against a local stand-in throughGOG_GOOGLE_API_BASE_URL. The stand-in is not Google: it answers each list with{}, as Google does for an empty list.Every
make cistep passed on1bc548a(go1.27.3); the head6653159only 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