fix: truncate large test result samples to prevent oversized alert payloads (#2044)#2302
Conversation
…yloads (elementary-data#2044) Test result samples rendered as an alert table had no upper bound on row count. Alerts with many failed/warning rows (e.g. 25+ rows with several columns) could grow large enough to be rejected by downstream integrations such as Microsoft Teams, causing edr monitor to crash before sending any alert. Cap the rendered sample at MessageBuilderConfig.maximum_rows_in_alert_samples (default 25, mirroring the existing maximum_columns_in_alert_samples knob) and append a note indicating how many rows were omitted when truncation occurs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
👋 @zerafachris |
|
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)
📝 WalkthroughWalkthroughChangesThe alert message builder adds a configurable maximum of 25 rendered result-sample rows, truncates larger tables, and reports shown and omitted counts. Unit tests cover both truncated and untruncated samples. Alert sample truncation
Estimated code review effort: 2 (Simple) | ~10 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 |
Fixes #2044
Test result samples rendered in an alert are converted into a table block with no upper bound on row count. When a failing/warning test has many rows (e.g. 25+ rows across several columns), the resulting alert payload can exceed size limits enforced by downstream integrations such as Microsoft Teams, causing
edr monitorto crash before any alert is sent.This adds a
maximum_rows_in_alert_samplesconfig option toMessageBuilderConfig(default 25, mirroring the existingmaximum_columns_in_alert_samplesknob) and truncates the rendered sample to that limit in_get_result_blocks, appending a note indicating how many rows were omitted.Added
tests/unit/alerts/alert_messages/test_result_blocks_row_truncation.py:maximum_rows_in_alert_samples=10is truncated to 10 rows with a "Showing 10 of 37 rows (27 omitted...)" note. Before this change:assert len(table_block.rows) == 10fails (assert 37 == 10). After: passes.Full unit suite (
pytest tests/unit): 453 passed. black/isort/flake8/mypy all clean on the touched files and across the package.Prepared with AI assistance (Claude, agent: claude-sonnet-5), reviewed for correctness before submission.
Summary by CodeRabbit
New Features
Bug Fixes
Tests