[#202] fix: quarantine malformed JSON in filedrop inbox #204

Merged
k9ert merged 1 commit from fix/filedrop-malformed-json into main 2026-03-05 19:49:25 +00:00
Collaborator

Closes #202

Problem

Malformed JSON in the filedrop inbox causes an infinite retry loop. The except block logs the error but leaves the file in the inbox, so the next poll cycle retries it forever.

Alpha was stuck in this loop for hours.

Fix

Added _quarantine_file() method that:

  1. Adds file to _processed set (stops retrying)
  2. Moves file to processed/ with _corrupted suffix
  3. Logs a warning

Both poll_inbox() and the secondary poll method now catch json.JSONDecodeError separately and quarantine the file.

Tests

3 new tests:

  • Malformed JSON is quarantined (removed from inbox, _corrupted suffix in processed/)
  • Good messages still process after a bad one
  • Second poll after quarantine is clean (idempotent)
Closes #202 ## Problem Malformed JSON in the filedrop inbox causes an infinite retry loop. The except block logs the error but leaves the file in the inbox, so the next poll cycle retries it forever. Alpha was stuck in this loop for hours. ## Fix Added `_quarantine_file()` method that: 1. Adds file to `_processed` set (stops retrying) 2. Moves file to `processed/` with `_corrupted` suffix 3. Logs a warning Both `poll_inbox()` and the secondary poll method now catch `json.JSONDecodeError` separately and quarantine the file. ## Tests 3 new tests: - Malformed JSON is quarantined (removed from inbox, _corrupted suffix in processed/) - Good messages still process after a bad one - Second poll after quarantine is clean (idempotent)
[#202] fix: quarantine malformed JSON in filedrop inbox
All checks were successful
CI / lint (pull_request) Successful in 9s
CI / test (3.11) (pull_request) Successful in 20s
CI / test (3.12) (pull_request) Successful in 22s
CI / test (3.13) (pull_request) Successful in 22s
E2E Tests / e2e (pull_request) Successful in 15s
CI / build (pull_request) Successful in 7s
b69c6f6917
Malformed JSON files in the inbox caused an infinite retry loop —
the except block logged the error but left the file in place, so
the next poll cycle retried it forever.

Now: JSONDecodeError and other exceptions move the file to
processed/ with a _corrupted suffix and skip it. Good messages
continue to process normally.

3 new tests covering quarantine, mixed good/bad files, and idempotency.

Closes #202
k9ert approved these changes 2026-03-05 19:48:40 +00:00
k9ert merged commit f3717983e1 into main 2026-03-05 19:49:25 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ultanio/cobot!204
No description provided.