fix: balance Telegram HTML chunks - #42
Conversation
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughTelegram publisher message splitting now uses an HTML parser to enforce visible-character limits and produce independently valid HTML chunks. Tests cover tags, entities, nesting, and newlines, while design documentation specifies the delivery behavior. ChangesTelegram HTML chunking
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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. Additional details and impacted files@@ Coverage Diff @@
## master #42 +/- ##
=======================================
Coverage 99.62% 99.63%
=======================================
Files 38 38
Lines 5944 5980 +36
Branches 323 325 +2
=======================================
+ Hits 5922 5958 +36
Misses 15 15
Partials 7 7 ☔ View full report in Codecov by Harness. |
e0c877b to
65ce112
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@weather_briefing/publishers.py`:
- Around line 269-273: Update _finish_chunk to avoid appending or emitting a
chunk when the accumulated content has zero visible characters, including
trailing empty markup such as an empty nested tag. Preserve the existing
closing-tag and open-tag state handling for chunks containing visible text, and
ensure empty markup is not sent as a separate request.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 67b7debc-4b8f-4f02-b291-99c2dba6cd40
📒 Files selected for processing (3)
docs/design.mdtests/test_publishers.pyweather_briefing/publishers.py
65ce112 to
db6d2a8
Compare
Summary
Root cause
The previous splitter only avoided cutting inside the text of a tag or entity. It did not track open tags across chunk boundaries, so long formatted content could produce an unclosed tag in one request and an orphaned closing tag in the next, causing Telegram Bot API rejection.
Validation
mise exec -- uv run --with pytest --with pytest-cov -- pytest --cov --cov-branch --cov-report=xml(546 passed; misses and partials unchanged)prek run --all-filesmaster(0 findings after one valid newline-preservation fix)Summary by CodeRabbit
Bug Fixes
Documentation