fix(worker): use json.dumps for redis.publish payloads#136
fix(worker): use json.dumps for redis.publish payloads#136JohnRDOrazio wants to merge 1 commit intodevfrom
Conversation
The ARQ worker built Redis pubsub payloads via f-string-formatted JSON.
This was fragile, and outright buggy in three places — `lint_failed`,
`normalization_failed`, and `remote_check_failed` interpolated `str(e)`
directly, so any exception message containing a `"`, `\`, or newline
produced invalid JSON for subscribers calling `json.loads(payload)`.
Replace every f-string JSON payload with `json.dumps({...})` (json was
already imported). Schema is preserved exactly: same `type` values, same
field names and order, UUIDs as strings, booleans as real booleans
(json.dumps emits `true`/`false`, replacing the prior
`str(x).lower()` workaround), ints as ints. Subscribers are unaffected.
Sites converted (11 total):
- lint_started, lint_complete, lint_failed
- normalization_status (status check task), normalization_started,
normalization_complete, normalization_failed,
normalization_status (per-project loop in cron)
- remote_check_started, remote_check_complete, remote_check_failed
Closes #111
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Closing as duplicate of #118 (opened 2026-04-27, includes a dedicated regression test for the |
Summary
ontokit/worker.pypreviously built Redis pubsub payloads via f-string-formatted JSON. This was fragile, and outright buggy in three places —lint_failed,normalization_failed, andremote_check_failedinterpolatedstr(e)directly into the JSON string, so any exception message containing a",\, or newline produced invalid JSON for subscribers callingjson.loads(payload).This PR replaces every f-string JSON payload with
json.dumps({...}).jsonwas already imported at the top of the file.Sites changed (11 total)
lint_started,lint_complete,lint_failednormalization_status(status check task),normalization_started,normalization_complete,normalization_failed,normalization_status(per-project loop incheck_all_projects_normalizationcron)remote_check_started,remote_check_complete,remote_check_failedSchema unchanged — subscribers unaffected
typevalues, same field names, same ordering.str(run.id)etc.).json.dumpsemitstrue/false, replacing the priorstr(x).lower()workaround. The wire format is identical.issues_found) remain ints.Test plan
ruff check ontokit/worker.py— passesruff format ontokit/worker.py— no changesmypy ontokit/worker.py(strict) — passespytest tests/unit/test_worker.py -v— all 51 worker tests pass (worker.py coverage 99%)json.dumps→json.loadswith adversarial error strings (containing",\n,\\)Closes #111
🤖 Generated with Claude Code
Summary by CodeRabbit