You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Firestore batch boundary overflow and document contention crashes in action_items database #19449
In \�ackend/database/action_items.py\ and \�ackend/routers/action_items.py, batch operations on action items are vulnerable to Firestore commit limit overflows (>500 operations) and duplicate document contention errors in high-volume workloads (\INV-MEM-5: Universal memory and task authority).
Failure Modes & Root Causes
Firestore Single Commit Contention:
In \delete_action_items_batch\ and \�atch_set_sync_requested, the input list of IDs is iterated without deduplication. Passing duplicate IDs (e.g. from rapid client sync retries or mobile retransmissions) causes Firestore commit to abort with:
\InvalidArgument: 400 Multiple operations on document in a single commit\
Missing 500-Op Commit Chunking:
\delete_action_items_for_conversation,
etire_action_items_for_conversation, \�atch_set_sync_requested, and \get_action_items_by_ids\ stream or iterate documents without commit chunking. Conversations or bulk operations with >500 action items crash with:
\InvalidArgument: A maximum of 500 operations are allowed on a commit\
Pinecone Vector Deletion Failure Cascades:
In \�ackend/database/vector_db.py:delete_action_item_vectors_batch, \index.delete\ is executed without exception handling. If Pinecone experiences transient network timeouts or degradation, an uncaught exception is raised after Firestore has already committed the deletions, returning an HTTP 500 to the caller.
Router Preflight Sanitization:
\�ackend/routers/action_items.py:batch_delete_action_items\ passes raw ID lists into both the locked-item preflight check and the database deletion layer without prior deduplication or whitespace sanitization.
Proposed Solution
Sanitize and deduplicate IDs preserving order before all batch commit loops.
Enforce 499-op commit chunking across all conversation deletion, retirement, sync, and batch-get operations.
Catch Pinecone exceptions in \delete_action_item_vectors_batch\ and log warnings so vector index transients do not fail transactional document deletions.
Validate \uid\ against empty/whitespace values.
Provide hermetic unit tests verifying L+1 boundary conditions (501 items), duplicate filtering, and failure isolation.
Submitted an independent, focused draft in #20729 for the duplicate-ID portion of this issue: deduplicate before delete/sync writes and lock-preflight reads, preserve exact IDs and first-occurrence order, and return/clean up distinct deletions once. Current main already has 499-write chunking for conversation deletion, retirement, and sync. This draft retains the 500-item router read preflight and strict vector-cleanup errors for account deletion.
44 focused tests pass, including an HTTP regression through the production router and DB writer with fake external services; backend typecheck, runtime source closure, OpenAPI compatibility/export and generated client contracts also pass. Full Windows query-driver preflight failures are documented in the draft; Linux CI is not yet reported. Implemented with OpenAI Codex assistance.
Is this focused fix eligible for a funded bounty? If so, please confirm the amount and acceptance criteria here. I have not assumed the proposed amount in #20724 is an approved reward.
Activity
Aj2280 commentedon Oct 5, 2026
I've submitted a fix for this issue in PR #20724: #20724 with hermetic unit test coverage and all 32 preflight checks passing.
edvinas1573 commentedon Oct 5, 2026
Submitted an independent, focused draft in #20729 for the duplicate-ID portion of this issue: deduplicate before delete/sync writes and lock-preflight reads, preserve exact IDs and first-occurrence order, and return/clean up distinct deletions once. Current main already has 499-write chunking for conversation deletion, retirement, and sync. This draft retains the 500-item router read preflight and strict vector-cleanup errors for account deletion.
44 focused tests pass, including an HTTP regression through the production router and DB writer with fake external services; backend typecheck, runtime source closure, OpenAPI compatibility/export and generated client contracts also pass. Full Windows query-driver preflight failures are documented in the draft; Linux CI is not yet reported. Implemented with OpenAI Codex assistance.
Is this focused fix eligible for a funded bounty? If so, please confirm the amount and acceptance criteria here. I have not assumed the proposed amount in #20724 is an approved reward.