fix(drive): reject repeated tree inventory page tokens - #1085
Conversation
listDriveChildren assigned NextPageToken with no seen-set, so a repeated Drive token hung gog drive tree, inventory, and du. Walk folder children through collectAllPages, matching drive sync push listing. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed September 5, 2026, 4:00 AM ET / 08:00 UTC. ClawSweeper reviewWhat this changesThe PR uses the shared pagination guard for Drive tree, inventory, and disk-usage reports, with regression coverage for repeated tokens, ordered results, and failed listings. Merge readiness⛔ Needs changes before merge - 2 items remain This PR remains necessary: current main and v0.39.0 retain the unguarded reporting loop, and the related merged fixes cover different callers. The implementation and supplied fault-injection proof are sound. Priority: P2 Review scores
Verification
How this fits togetherDrive reporting commands fetch folder contents through Google's Drive client, then traverse those results to produce tree, inventory, or storage reports. Pagination failures must reach the command before it emits a successful report. flowchart TD
A[Drive reporting command] --> B[Folder traversal]
B --> C[Drive file listing]
C --> D[Shared pagination guard]
D -->|Another distinct token| C
D -->|Complete listing| E[Build report]
D -->|Repeated token or error| F[Error without success output]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep one pagination policy across Drive scanners, preserving ordered results and rejecting incomplete reports without partial success output. Do we have a high-confidence way to reproduce the issue? Yes: two Drive responses returning the same nonempty nextPageToken cause current main to request that page again. Source inspection establishes the defect; the contributor supplies before/after fault-injection results, and this read-only review did not execute tests. Is this the best way to solve the issue? Yes: delegating to the existing collector is the narrowest maintainable repair, and the inspected callers preserve output and error behavior. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 25703c789da5. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Superseded by #1087, which incorporates cycle protection for Drive tree, inventory, and disk-usage scans. All three stock CLI commands were verified to fail without partial success output. Thanks @SebTardif. Superseded by #1087, which incorporates Gmail query-cycle protection, including repeated empty pages, while retaining existing result limits. Failure occurs before downstream message changes. Thanks @SebTardif. |
What Problem This Solves
gog drive tree,gog drive inventory, andgog drive duwalk folder children throughlistDriveChildrenininternal/cmd/drive_reporting.go. That helper copiednextPageTokeninto the nextFiles.Listrequest with no seen-set.When Drive repeats a continuation token, the loop never terminates. Tree, inventory, and disk-usage scans keep requesting the same page and never return.
The same hang class is already closed for Drive sync push listing (#1065), Drive audit permission listing (#1066), calendar and Gmail listing (#1004), and People/Gmail-from-contact/contacts-export listing (#1044, #1045, #1046). Folder children used by the read-only reporting commands were still on the unguarded loop.
Evidence
terminal output from the compiled
internal/cmdlisting binary after the patch. A stuck continuation token is rejected after two list calls, with no third request. The same error reaches the public commands:Before the patch, the same stuck token made a third list request and returned HTTP 400 from the safety cap (
unexpected extra page request after 3 list calls) instead of stopping on the repeated token.Real behavior proof
fix/drive-children-page-tokenfromorigin/mainat25703c78, compiledinternal/cmdlisting binary.go, then rangogcli-drive-reporting.exewith-test.von the helper hang-guard and the publicdrive tree/drive inventory/drive ducommand path.pagination loop: repeated page token "stuck"after 2 list calls forlistDriveChildren, andlist Drive folder root: pagination loop: repeated page token "stuck"with empty stdout for tree, inventory, and du.orderBy=folder,name, anddriveFilesListCallWithDriveSupport(corpora=allDrives) are unchanged.Summary
Route
listDriveChildrenthrough existingcollectAllPages. Keep the original query, fields, page size, order, shared-drive flags, and empty-parent default toroot.Related: #1065, #1066, #1004, #1044, #1045, #1046.
Introduced in
e9c496ef(2026-05-05,feat(drive): add read-only reporting commands, #554).