In an offline field-inspection mobile app, the server rejects a queued finding with 422 on every attempt and later entries depend on it; how should the outbox keep draining, and what does the technician see?
answer
- classify before retrying
- retry later versus never as sent
- 401 pauses, it does not park
- park it, block its dependants
- fix means a new key
basics
~20 sClassify the response: temporary failures retry later with backoff, but a 422 will fail again unchanged. Park that entry with its error, hold everything that depends on it, keep draining unrelated entries, and show the technician a fix-or-discard choice.
solid answer
~50 sThe queue first decides what the response means. No connection, timeouts, 5xx, 429 and a 409 saying the same key is still in progress are temporary: keep the entry, back off, honour `Retry-After`. A 401 pauses the whole queue until the user signs in again. A 412, or a 409 for a state conflict, goes to the conflict policy. A 400, 422, 403, or a 404 for a deleted parent will fail again if resent unchanged, so the entry is **parked** with its error. Entries that depend on it - later edits to that finding, the job's close - are held as blocked, while unrelated entries and other inspections keep draining. Nothing is deleted silently. The technician sees '1 finding couldn't be sent' with the reason, and chooses to fix it, which sends a new entry with a new key, or to discard it along with its dependants.
code
pseudocode · 31 linesfunction drain_lane(lane):
while lane has a pending entry whose next_attempt_at has passed:
entry = oldest such entry
if entry depends on an entry whose state is "parked" or "blocked":
entry.state = "blocked"
go to the next entry
in one transaction:
entry.state = "in_flight"
if entry.first_sent_at is empty: entry.first_sent_at = now()
result = send(entry, idempotency_key = entry.idempotency_key)
if result is success:
in one transaction: apply result to local records; delete entry
else if result is no_network or timeout
or result.status in (500, 502, 503, 504, 429)
or (result.status = 409 and result says key in progress):
entry.state = "pending"
entry.attempts = entry.attempts + 1
entry.next_attempt_at = backoff(entry.attempts, result.retry_after)
stop draining this lane
else if result.status = 401:
entry.state = "pending"
pause all lanes until the user signs in
stop draining this lane
else if result.status = 412 or result.status = 409:
entry.state = "pending"
hand entry to the conflict policy
stop draining this lane
else:
entry.state = "parked"
entry.last_error = result.body
mark every entry that depends on it as "blocked"go deeper
Recall that some server rejections will never succeed if the same write is resent, and that such a write must be set aside and shown to the user rather than retried forever.
Explain how each status class maps to a queue action - retry later, pause for sign-in, conflict policy, or park - and why 409 and 422 need their response body read.
Show how parking one entry blocks only its dependants, keeps other lanes moving, never deletes data silently, and gives the user a fix-or-discard path with a new key.
Set one rejection taxonomy and parked-entry policy shared by every feature that writes offline, with server teams committing to error bodies the client can classify.
## The situation A technician adds a finding with a 900-character description. Offline, the app accepted it; the server's limit is 500, so every attempt comes back **422 Unprocessable Content**. Behind it in the inspection's lane sit two edits to that finding and the `close_inspection` entry. A naive queue either retries the finding forever, so nothing behind it ever leaves the phone, or drops it, so the finding - part of the job's evidence - disappears. This is a **poison entry**: one that will never succeed as it stands. ## Classify the response before deciding "Retry" and "give up" are not enough. The status tells the queue which of four things to do: | Response | What it says about this entry | Queue action | |---|---|---| | No connection, timeout, 500, 502, 503, 504 | Unknown or temporary | Keep it; back off and retry the lane later | | 429 Too Many Requests | Slow down | Keep it; wait at least the `Retry-After` delay when one is sent | | 409 saying the same key is still being processed | The first attempt is in progress | Keep it; retry later, unchanged | | 401 Unauthorized | Credentials missing or expired | Pause the whole queue until the user signs in again | | 412 Precondition Failed, or 409 for a state conflict | The record changed on the server | Hand the entry to the conflict policy | | 400, 422, 403, or 404 / 410 for a deleted parent | Resending unchanged will fail again | Park it | Three rows need care: - **401 is not about this entry.** It should not count as an attempt or park anything; one platform's offline-first guidance says not to retry unauthorised requests until proper credentials are available. Refreshing the token is the request layer's job - the queue sees 401 only when that failed. - **409 is ambiguous.** The idempotency-key draft uses it for "still processing", while HTTP defines it as a conflict with the resource's current state. The response body has to say which. - **422 has two causes here.** A validation failure, or - under the draft - a key reused with a different payload, which is a client bug. Neither is fixed by resending unchanged. How long to back off, and with what jitter, is a topic of its own; the queue's decision is which entries back off at all. ## Park the entry, hold its dependants, keep draining A **parked** entry leaves the head of its lane with its error saved. Then: 1. Every entry that depends on it - later edits to the same finding, anything that references it - is marked **blocked** and not sent. Sending them would fail on a missing record or leave half a job on the server. 2. Entries in the same lane that do not depend on it keep going, and so does every other inspection's lane. 3. The `close_inspection` entry depends on all the job's findings, so it is blocked too: a job should not be closed on the server with a finding missing. 4. Nothing parked or blocked is deleted automatically. The user may fix it, or a later build may be able to send it. ## What the technician sees Parking is invisible unless the app says so. The job shows "1 finding couldn't be sent - description longer than 500 characters" with two actions: - **Fix and resend.** The corrected finding is a new payload, so it goes out as a new entry with a new key; the draft forbids reusing a key with a different payload. Its blocked dependants are released, in their original order, once it succeeds. - **Discard.** The finding and its blocked dependants are dropped together, and the screen's local values are rolled back - how that rollback looks belongs to the design of optimistic state. Entries that are only waiting for coverage are not errors and need no alarm. ## Entries that neither fail nor succeed Some entries sit in "retry later" for days: a server answering 503 through a long outage, or a request that always times out. Give each entry an attempt or age ceiling. Past it, mark it **stuck** - still retried now and then, never deleted - so it counts in the app's sync status and the technician is told to reach coverage or contact support. Reporting parked and stuck counts in the app's telemetry turns a validation mismatch between app and server into a bug report rather than a lost inspection.
- The technician fixes the finding's text. Does the corrected entry reuse the old key?No. The payload has changed, and the draft says a key must not be reused with a different payload. The fix commits a new entry with a new key in the parked entry's place in the lane; when it succeeds, the blocked dependants are released in their original order.
- An entry has been timing out for three days. Should the queue give up?It should stop treating the entry as routine but never delete it silently. Past an attempt or age ceiling, mark it stuck, keep retrying occasionally, count it in the visible sync status and report it in telemetry. Requests that always time out are often a size or server problem that only a person can resolve.
- Retry every 4xx with backoff; the server will accept it eventually.
- Drop any entry the server rejects with a 4xx and carry on.
- One rejected entry should stop the whole queue until it succeeds.
- Send the dependants anyway; the server will cope with the missing finding.
- A 401 means this write is invalid and should be parked.
- After fixing a rejected payload, resend it under the original key.