fix(worker): use json.dumps for redis.publish payloads#118
Conversation
|
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 (2)
📝 WalkthroughWalkthroughThe changes replace f-string JSON payload construction in Redis publish calls with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 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✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Replaces 11 hand-rolled f-string JSON payloads in worker.py with
json.dumps({...}). The f-string approach worked by accident for fields
holding only UUIDs and ints, but the *_failed handlers interpolated
str(e) directly — exception messages routinely contain quotes and
newlines (e.g. `'foo' has no attribute "bar"\nstacktrace`), which
produced unparseable JSON and broke any subscriber that does
json.loads on the payload.
Affected handlers (worker.py):
- lint_started / lint_complete / lint_failed
- normalization_started / _complete / _failed / _status (×2)
- remote_check_started / _complete / _failed
The newer index_*, consistency_*, and duplicates_* handlers were
already using json.dumps; this brings the rest in line.
Channel names, message types, and field names are unchanged so existing
subscribers continue to work without modification.
Adds test_lint_failure_payload_is_valid_json_with_quoted_error: invokes
run_lint_task with a RuntimeError whose message contains both `"` and
`\n`, then asserts the published lint_failed payload round-trips through
json.loads. Locks in the regression.
Closes #111
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5f11dcc to
866e27f
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Replaces 11 hand-rolled f-string JSON payloads in `worker.py` with `json.dumps({...})`. The f-string approach worked by accident for fields holding only UUIDs and ints, but the `*_failed` handlers interpolated `str(e)` directly — exception messages routinely contain `"` and `\n` (e.g. `'foo' has no attribute "bar"`), which produced unparseable JSON and broke any subscriber that does `json.loads` on the payload.
What changed
Affected handlers in `ontokit/worker.py`:
The newer `index_`, `consistency_`, and `duplicates_*` handlers were already using `json.dumps` — this brings the rest in line.
Channel names, message types, and field names are unchanged, so existing subscribers continue to work without modification.
Closes #111
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests