Skip to content

Fail a job with an unreadable evidence payload once instead of forever - #41

Merged
alexeybe1kin merged 2 commits into
mainfrom
glm/memorygate-unreadable-payload-fails
Oct 31, 2026
Merged

alexeybe1kin merged 2 commits into
mainfrom
glm/memorygate-unreadable-payload-fails

Conversation

@alexeybe1kin

Copy link
Copy Markdown
Collaborator

From bugs-memorygate-2 BUG-5.

The worker read json.loads(evidence.normalized_payload_json or "{}").get("content") before it called process_evidence. A payload that is not JSON, or is JSON but not an object, raised at that read. The loop's except Exception: db.rollback() caught it, so the job stayed processing with its lease. Each time the lease ran out, the job was claimed again and failed the same way.

What changed:

  • The body of the worker loop moved into run_job(db, job), which can be tested.
  • run_job parses the payload. If it can't, it calls _fail, which fences the lease, marks the job failed and quarantines the evidence, as process_evidence does on failure.
  • The missing-evidence branch also uses _fail. Its result is unchanged.

Evidence:

  • Test: test_an_unreadable_payload_fails_the_job_once, parametrized over not-JSON and a JSON list. After the job fails, a later claim past the old lease returns None.
  • Mutant: a bare raise in the handler fails both cases.
  • 87 tests passed in the four affected suites; ruff, file sizes and package boundaries are clean.
  • stale_anchors() is [].

GLM wrote the change. Claude reviewed it and ran the mutant.

🤖 Generated with Claude Code

alexeybe1kin and others added 2 commits October 31, 2026 12:05
A payload that is not JSON, or JSON that is not an object, raised inside the
worker loop before process_evidence, so the job kept its lease and came back
every time the lease ran out. run_job now parses it and fails the job with the
evidence quarantined, as process_evidence does for any other failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…able-payload-fails

# Conflicts:
#	CHANGELOG.md
@alexeybe1kin
alexeybe1kin merged commit 3532ac2 into main Oct 31, 2026
3 checks passed
@alexeybe1kin
alexeybe1kin deleted the glm/memorygate-unreadable-payload-fails branch October 31, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant