Repository navigation
fix(platform): lists and transfers tell the truth about their bounds - #3166
Merged
Merged
Conversation
The discussion read was a fixed oldest-200 window on the message store, so
a busy task's 201st comment saved (POST 200) and rendered nowhere — the UI
feed, REST GET /tasks/{id}/comments, and the task.list_comments native all
shared it. The feed now reads from the thread's tail: a newest-first keyset
page in the threads store (`listThreadMessagesTail`), `numItems`/`cursor`
on the app door with the `{page, isDone, continueCursor}` envelope the
infinite-query lane walks, `limit`/`cursor` + `isDone`/`continueCursor` on
REST (the GET now also survives into the published spec), `truncated` on
the native and its declared mock, and a "show earlier comments" walk in the
task panel. Integration check: 522 comments paged 200/200/122 on every door.
pgDocumentStore.listFolder answered `truncated: false` unconditionally over a 200-row cap, "the folder does not exist" for every folderPath, and ignored recursive — an automation iterating a 201-file folder skipped one while being told the listing was whole. The store now resolves folderPath through the folders domain's hub path walk, walks subfolders breadth-first when asked (names prefixed with their path, depth-bounded), and reports the real truncation bit, judged on the stored rows before the access filter so a hidden row never masks a cut. Same mechanism on the WebDAV connector native: `webdav.list` now carries the tree handler's `truncated` bit through instead of dropping it. Integration check: 201 files → 200 + truncated, folderPath resolves, recursive prefixes names, missing → error.
The sync/import download lane did `await download.arrayBuffer()` with no Content-Length check and no timeout, and the direct upload POST buffered its whole body the same way; the 512 MB ceiling in `putOrgBlobBytes` only fired AFTER the bytes were in the heap, so one multi-GB vendor file could OOM the shared worker and a stalled Graph download parked a sync forever. Both lanes now read through `readBodyBounded`: the declared length is refused before a byte is read (413 FILE_SIZE_INVALID), the received bytes abort at the first chunk past the cap, and the vendor fetch carries a 15-minute AbortSignal timeout. The import pipeline's stale "streaming Convex action" comment now describes the pg lane.
`listFiles` took Graph's first `/children` page (`$top=100`, search 50) and `listSharePointFiles` its first 200, neither following `@odata.nextLink` — a 300-file folder showed 100 in the picker, and because the import dialog expands selected folders through these listers, a one-time folder import quietly imported 100 and reported success (SharePoint never syncs, so nothing healed it later). Both listers now walk every page through a shared Graph collection pager up to a 10k-item bound (500 for search) and answer `truncated` when the bound cut the walk. The picker says so under the table, and folder expansion refuses a truncated or failed listing instead of importing part of a folder as a success. Integration check: a 250-child folder browses whole across three fake Graph pages, and the oversized-download refusal lands unread on the same fake drive.
…actly The connector door throws its coded refusals; the new listing check now records a thrown refusal (or an off-shape answer) as its own failure instead of aborting the probe, and asserts the INPUT_INVALID for a path that names no folder. The oversized-download fake streams with highWaterMark 0, so its pull count means "someone read the body" rather than the stream's construction-time pre-fill.
The Microsoft 365 import now refuses a folder it cannot list whole instead of importing part of it; the Documents page says so in every locale.
larryro
marked this pull request as ready for review
September 3, 2026 07:46
# Conflicts: # services/platform/backend/integration-check.ts # services/platform/public/openapi.json # services/platform/scripts/generate-openapi.ts
larryro
added a commit
that referenced
this pull request
Sep 6, 2026
The Google Drive browse/search lister followed `nextPageToken` with no bound — pageSize 100, `includeItemsFromAllDrives`, and for a search `name contains '<q>'` across the tenant — so a short search term over a large Workspace tenant with shared drives ran hundreds of sequential Drive calls and grew an unbounded array inside one HTTP request after a single rate-limit charge. The OneDrive twin got its bound and `truncated` flag in #3166; the Drive twin was missed, and its picker consumed no such flag. `listFiles` now stops at 10,000 items for a folder browse and 500 for a search (plus a page-walk fail-safe) and reports `truncated`; the contract, the hook and the Google Drive picker carry it: the picker names the cut under the table (the shared copy the OneDrive picker uses, like the table's own empty state), and a folder import refuses a folder it cannot list whole instead of importing the rest and calling that a success — a sub-listing failure now fails the import the way the OneDrive picker does, rather than toasting and importing around the hole. Docs name the refusal for Google Drive as they already did for Microsoft 365. Finding: cloud-drives-5.
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The invariant
A bounded list or transfer tells the truth. Either it returns everything (pages to the end), or it says precisely that it was cut and how to continue — and it never trusts an unbounded input into memory. Every finding below is a lane that silently dropped data a user or agent had no way to notice was missing.
Per finding
1. Task comments silently capped at the OLDEST 200 —
fix(platform): page task discussions from the newest commentlistTaskComments→listThreadMessageswith no options → the store's defaultLIMIT 200 … ORDER BY "order" ASC. The first 200 comments won forever; a 201st comment saved (POST 200) and rendered nowhere — UI feed, RESTGET /tasks/{id}/comments, and thetask.list_commentsnative all shared it.listThreadMessagesTail,(order, step_order)cursor, limit+1 forhasMore);listTaskCommentspages from the tail (limitdefault 200, max 500,beforecursor). App door answers the{page, isDone, continueCursor}envelope the infinite-query lane already walks (newest first; bad cursor → 400); REST answers{comments, isDone, continueCursor}withlimit/cursor(the GET also survives intoopenapi.jsonnow — the POST block used to reassign the path and clobber it); the native returnstruncated(declared mock updated). The task panel walks older pages with Show earlier comments (en/de/fr) and shows the task-wide count.app/lib/backend/tasks.test.ts(cursor walk),task-comments.test.tsx(earlier-pages control at the oldest end, count), natives wiring test; itestcheckTaskDiscussionPaging— 522 comments paged 200/200/122 newest-first, REST walk covers every id exactly once, nativetruncated: true.2.
document.listreportedtruncated:falseover a 200 cap and dead-ended on folderPath/recursive —fix(platform): document.list tells the truth about its folder listingpgDocumentStore.listFolderhardcodedtruncated: false, returnednull("the folder does not exist") for everyfolderPath, ignoredrecursive.folderPathresolves through the folders domain's existingfindHubFolderByPath;recursivewalks subfolders breadth-first (collectWorkflowFolderFiles, names prefixed with their path,MAX_FOLDER_DEPTH-bounded);truncatedis real — judged on stored rows before the team filter (listFolderDocumentsBounded), so a hidden row never masks a cut, and conservative when the cap is reached with folders still unread.webdav.listdropped the tree handler'struncatedbit — it now rides theWebdavStore.listcontract and the native output (declared mock updated).document-listing.test.ts(8 cases: exact cap, over cap, recursive prefixes, depth bound, root),webdav.test.tstruncated pass-through; itestcheckWorkflowDocumentListing— 201 files → 200 +truncated,folderPathresolves, recursive prefixes, missing path → coded refusal.3. OneDrive/SharePoint pickers and one-time folder imports silently truncated —
fix(platform): page OneDrive and SharePoint listings to the endlistFilestook Graph's first/childrenpage ($top=100, search 50),listSharePointFilesits first 200; neither followed@odata.nextLink. The import dialog expands selected folders through them, so a 300-file folder imported 100 and toasted success.graph_collection.ts) follows@odata.nextLinkto the end, bounded at 10k items (500 for search) withtruncatedwhen the bound cut it. Both listers use it; the picker shows a notice under the table when the shown folder holds more; folder expansion refuses a truncated or failed listing instead of importing part of a folder as a success (en/de/fr strings; Documents docs page notes it).list_files.test.ts(multi-page whole, bound → truncated, overflow page trimmed, error contract, SharePoint folders-first), dialog tests (truncated folder → no import + destructive toast, failed listing → stop, notice shown/absent); itest — a 250-child folder browses whole across three fake Graph pages.4. Sync/import downloads buffered the whole vendor file before the size cap —
fix(platform): refuse oversized downloads and uploads before bufferingfetchVendorContentToStoragedidawait download.arrayBuffer()with no Content-Length check and no timeout;putOrgBlobBytesenforced 512 MB only after the bytes were in the heap.readBodyBounded(files domain) refuses the declaredContent-Lengthbefore reading a byte (413FILE_SIZE_INVALID) and aborts a chunked body at the first chunk past the cap; the vendor fetch carries a 15-minuteAbortSignal.timeout. Folded medium:POST /api/app/files/uploadbuffered the request body the same way — same guard.bounded-body.test.ts(declared-length refusal reads 0 chunks, over-cap stream aborts at chunk 3 of 10, exact cap accepted); itest — an import of a file declaring 600 MB fails its own row with the limit message and the fake body sees 0 pulls.Already fixed / refuted in the base
Verification (observed)
tsc --noEmit: clean. Platformoxlint --type-aware(whole workspace): clean.app/routes/**files fail on both (Vite "Denied ID" for@fontsourcethrough the worktree's symlinkednode_modules— environmental).task-comments.test.tsx12/12,onedrive-import-dialog.test.tsx6/6. i18n parity: 48/48. Docs workspace tests 30 files / 194 pass;@tale/uitests 123/124 files with the same single environmental@fontsource"Denied ID" failure on base and branch. Red-on-base for the colocated tests (run against the untouched base copy):list_files.test.tsfails at file level, the adapter cursor test fails, 10 of the two UI files' tests fail.integration-check.ts): 343/347 — exactly the four new checks fail on base (old{messages}envelope and cursor-less window withbadCursor=200;document.listanswerstruncated=falseover 201 files and throws onfolderPath; OneDrive browses 100 of 250 children; the 600 MB download is read whole — 65 chunks — and imported as a success), every pre-existing check passes.Cross-class discoveries
scripts/generate-openapi.tsreassignedpaths['/api/v1/tasks/{id}/comments']for the POST and dropped the GET from the published spec (fixed here since the GET's shape changed).userId: 'system', no team memberships) hides team-scoped hub documents/folders fromdocument.list— pre-existing scoping, unchanged;truncatedis judged before that filter so it stays honest.findFolderByPathnext tofolders/paths.ts's validating one — left alone (semantics differ for legacy names).