fix(backup): preserve service action metadata in raw_data#191
Conversation
Historical backfills store service messages but drop message.action, losing metadata the live listener already preserves since v6.0.0 (raw_data.service_type / action_type / new_title). Capture the action type (normalized class name) and, when present, the title via the existing TextWithEntities helper. Forum topic creations and renames become auditable and linkable: topic_create via messages.id, topic_edit via reply_to_top_id. No schema change, no new logs.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR extends message processing to capture and store Telethon service-action metadata during historical backfills, ensuring forum topic creates/edits and similar events preserve action payloads (type, title) consistently with the live listener path. ChangesService action metadata preservation
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
|
Thanks for this, @cdelalama — it's a genuinely well-crafted PR. 🙏 You opened a precise issue first, scoped the fix to the actual seam ( I ran a deep multi-agent review anyway (Telethon-API, logic, tests, architecture, simplicity) and verified the key claims against the installed Telethon 1.43.2 source and an empirical repro rather than from memory. Sharing the findings for transparency — none block merge; the verdict is approve, with a couple of small follow-ups you might consider. Verified correct ✅
Worth a look (non-blocking)1. (nit, test hygiene) One mock factory still omits They still pass (their assertions only check 2. (minor) "Parity with the listener" is structural, not value-level. The 3. (minor, cosmetic) Acronym class names snake-case oddly. 4. (FYI, out of scope) Backfilled service messages render as empty bubbles. One small thing you could fold in now
Net: clean, correct, safe to merge as-is — the only thing I'd genuinely suggest before merge is the one-line test-fixture pin (#1). Everything else is polish or a follow-up. Really nice work, and thanks again for contributing this. 🙌 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #191 +/- ##
==========================================
+ Coverage 92.24% 92.25% +0.01%
==========================================
Files 25 25
Lines 7130 7141 +11
==========================================
+ Hits 6577 6588 +11
Misses 553 553
🚀 New features to boost your workflow:
|
Same MagicMock-truthiness guard the other fixtures use: without it the extended tests flow a truthy mock action through the new service-action capture and store phantom metadata in raw_data.
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
…rgence (#192) Follow-up to #191 review: - Move service_action_type to message_utils.py beside extract_topic_id (both paths' shared home); drop the now-unused re import in telegram_backup.py. - Docstring notes the acronym snake-case edge (SetMessagesTTL -> set_messages_t_t_l) and that the backfill action_type vocabulary is intentionally distinct from the listener's curated event names — only the raw_data shape is shared, not the values. - Reword the _process_message comment to say structural parity (keys), not value parity. - Add direct unit tests for service_action_type (topic, multi-word, no-arg, acronym edge) and a non-topic MessageActionChatEditTitle / MessageActionPinMessage backfill test.
Summary
_process_message) now preservemessage.actionmetadata inraw_data, restoring parity with the live listener's convention (service_type/action_type/new_title, in place since v6.0.0).topic_createlinks viamessages.id == forum_topics.id;topic_editviareply_to_top_id.new_titlegoes through the existing_text_with_entities_to_stringhelper.Type of Change
Database Changes
scripts/Data Consistency Checklist
chat_idvalues use marked format (via_get_marked_id()) — no chat_id handling changed_strip_tz()before DB operations — no datetime handling changedTesting
python -m pytest tests/ -v) — 1847 passed on Python 3.14ruff check .)ruff format --check .)Security Checklist
Deployment Notes
action_titleinstead ofnew_title, or the listener's curated vocabulary foraction_type).Summary by CodeRabbit