Skip to content

fix(backend): isolate cloud task sync failures per item - #19460

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
aryanorastar:codex/task-sync-batch-isolation
Sep 28, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
aryanorastar:codex/task-sync-batch-isolation

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #19459.

One failed external task export no longer aborts the rest of a conversation's cloud-sync batch or relabels earlier successful exports as failures.

  • Keep the failure boundary inside the existing sequential cloud export loop and return one result per input item, in order.
  • Continue after per-item database reads, OAuth preflight, or export-marker writes raise. Keep shared integration admission checks outside that boundary.
  • Preserve provider-reported failures, already-exported deduplication, and cancellation. Do not introduce automatic retries or additional concurrency.
  • Log the exception class rather than its contents at the new boundary, emit the shared degraded telemetry event, and return a generic per-item error.
  • Document the best-effort delivery boundary in the existing conversation-pipeline guide.

Reproduction and evidence

The conversation processor saves extracted tasks, then submits auto_sync_action_items_batch. Previously one outer try covered every cloud export. A failure on item 1 skipped item 2 and replaced item 0's successful result, even though its external task had already been created and marked exported.

The new behavioral suite executes the real batch worker and shared task-creation helper, with fault-injected database boundaries and HTTP provider stubs. On base 0e52d65c4028, 7 tests failed and 4 passed. After the fix, all 11 pass:

  • Read and export-marker failures at first, middle, and last positions: six cases.
  • An OAuth preflight exception between successful Asana exports.
  • Provider rejection together with an already-exported item; ordered results preserved.
  • Cancellation propagates without attempting the remaining tasks.
  • Missing/disconnected integration rejects the entire batch without contacting the provider.

The read/write cases also verify actual provider calls, stored export markers, one degraded telemetry event, and no raw exception content in the new log boundary.

Local HTTP verification

Ran a local Uvicorn harness on 127.0.0.1:10278, calling the real export worker / shared provider helper with synthetic database boundaries. Outbound Todoist requests were redirected to a loopback provider stub; this is not a production Todoist or full conversation API end-to-end test.

curl --fail-with-body -X POST http://127.0.0.1:10278/repro/read
curl --fail-with-body -X POST http://127.0.0.1:10278/repro/write
curl --fail-with-body -X POST http://127.0.0.1:10278/repro/none
Fault on middle task Ordered synced results Provider creates Saved export markers
Database read [true,false,true] Task 0, Task 2 task-0, task-2
Export-marker write [true,false,true] Task 0, Task 1, Task 2 task-0, task-2
None [true,true,true] Task 0, Task 1, Task 2 task-0, task-1, task-2

Every run attempted all three inputs. The write-failure case deliberately proves that the uncertain task is not automatically recreated.

Verification

  • backend/.venv/bin/pytest -q backend/tests/unit/test_task_sync_batch_isolation.py backend/tests/unit/test_task_sync_cloud_export_dedup.py backend/tests/unit/test_task_sync_async.py backend/tests/unit/test_task_sync_apple_async_boundary.py — 20 passed.
  • Selected-suite BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-19459-tests.txt BACKEND_PYTEST_WORKERS=3 bash test.sh from backend/ — 46 passed across 11 files, including all existing task-sync/task-integration suites and universal task-authority checks.
  • backend/scripts/typecheck.sh — 0 errors, 8,142 existing warnings.
  • OMI_PR_BODY_FILE=/tmp/omi-19459-pr-body.md make preflight — 30 selected checks passed. Metadata validation after committing — 4 checks passed. The history-dependent 90-day failure-class recurrence check explicitly skipped on this shallow clone; full-history CI remains authoritative.
  • Normal git push — bounded pre-push gate passed, no bypass. Local HTTP server stopped after verification.

Scope / limits

Product invariants

No mandatory invariant path citations. This preserves the existing integration and task-authority boundaries; no new integration surface or permission is introduced.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

Review in cubic

Failure-Class: FC-batch-fault-domain-head-of-line-poison

Preserve ordered successful outcomes and attempt remaining independent exports after a per-item database or OAuth failure. Refs BasedHardware#19459.
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified the fix end to end against head e0a9e20:

  • backend/utils/task_sync.py — the new per-item try/except sits exactly at the cloud export loop. It logs only the exception class (type(e).__name__), returns a generic Auto-sync failed result, and emits the shared record_fallback degraded event with allowlisted labels (component other, reason other), matching the fallback-telemetry contract. Since except Exception does not catch asyncio.CancelledError on Python 3.11, cancellation still propagates, and the new suite covers that. Shared admission checks (missing/disconnected integration) stay outside the boundary and the Apple Reminders single-push path is unchanged, as described.
  • backend/tests/unit/test_task_sync_batch_isolation.py — genuinely behavioral: it runs the real batch worker through fault-injected database seams and httpx.MockTransport provider stubs (Todoist + Asana), covering read/write faults at first/middle/last positions, OAuth refresh failure mid-batch, provider rejection + already-exported dedup with ordered results, cancellation, and whole-batch admission rejection. All 11 pass locally in the worktree.
  • backend/docs/listen_pusher_pipeline.mdx — the 10-line addition accurately documents the best-effort export boundary, including the no-automatic-retry rationale (a provider may have accepted a task before a local marker-write failure).

I also checked the sole caller (_write_action_items in utils/conversations/process_conversation.py): it discards the result list, so the per-item result shape is safe there.

One CI note: the Backend unit suite is red, but the two failing tests (tests/unit/test_chat_first_proactive_engine.py::test_desktop_meeting_adapter_uses_stored_role_and_skips_non_meeting_or_rotation and ::test_meeting_treatment_requires_five_minutes_and_deduplicated_speech) reproduce identically on this PR's parent commit 0e52d65c — they are pre-existing on main and unrelated to task sync. The task-sync gauntlets and hermetic E2E are green. That main-branch breakage deserves a separate fix so this PR's unit CI can go green.

Thanks for the careful isolation work and the strong test suite.

Automated maintainer review on David's behalf — AI-generated feedback; a human maintainer should confirm before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added backend Backend Task (python) positive-signal Automation verified a genuine fix/quality contribution labels Sep 27, 2026
…-isolation

# Conflicts:
#	backend/utils/task_sync.py
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Merged current main (d72de37).

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend bug fix (aryanorastar, trusted): isolates per-item cloud task sync failures so one failure no longer aborts the rest of the batch or mislabels earlier successes. Fixes #19459 (real filed bug). Scoped, extensively tested, CI green. Confidence 5/5 — merging.

@kodjima33
kodjima33 merged commit 11746ad into BasedHardware:main Sep 28, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: one task export failure aborts remaining cloud sync and overwrites successful results

3 participants