Skip to content

Offline sync: a recording older than 30 days fails with no explanation and burns its retry budget #10975

Closed

Description

@mdmohsin7

Symptom

A WAL older than SYNC_BACKFILL_MAX_AGE_SECONDS (2592000 = 30 days, set in backend/deploy/runtime_env.yaml) can never sync, and the app gives the user no reason why. It shows up as a generic failed after three attempts.

Evidence

Backend side — classify_sync_lane sets automatic_recovery_allowed=False past the window (backend/utils/sync/lanes.py:103-112), and both sync routes reject it:

if not lane_decision.automatic_recovery_allowed:
    return JSONResponse(
        status_code=422,
        content={'code': 'backfill_lookback_exceeded', ...},
    )

App side — uploadLocalFilesV2 in app/lib/backend/http/api/conversations.dart has no 422 branch. 422 is not 200/202/400/413/429/503-capacity/>=500, so it falls through to:

throw Exception('Upload failed unexpectedly');

That is caught by the generic batch handler, which increments retryCount. At retryCount >= 3 the WAL renders as WalSyncDisplayState.failed (app/lib/services/wals/wal.dart:152) with no message distinguishing "we cannot process this" from "this is permanently outside the recovery window".

Impact

Anyone draining a backlog older than a month — exactly the long-offline case sync exists for — spends three upload attempts per file on a rejection that can never succeed, and ends with an unexplained failure state.

Two decisions here, worth separating

  1. Should the 30-day cliff exist at all? A user who left a device offline for six weeks is a normal offline-sync user, not an abuse case.
  2. Regardless of (1), the app must handle 422. Parse backfill_lookback_exceeded, treat it as terminal instead of retryable, and say so in the UI.

Found while collapsing the app-side two-lane sync model; deliberately left out of that change to keep it scoped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions