Repository navigation
fix: don't crash send-report when Slack is configured with a webhook - #2366
EladBarkay merged 3 commits into
Conversation
With a Slack webhook in the config and a bucket upload that returns no website URL, send-report tried to attach the HTML file through SlackWebhookClient, whose send_report raises NotImplementedError. The command crashed after the report had already been uploaded and the summary posted. Skip the attachment for webhook clients and log why instead.
|
👋 @breken-ai |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesSlack report delivery
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Webhook reports avoid the unsupported attachment call while retaining report delivery, and token-based clients still receive attachments. No actionable merge risk is evident. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The webhook fix avoids a crash, but a successful Slack summary can make the report appear successful after its bucket upload fails, even though no HTML report was delivered. No new credential or data-access authority was identified. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
edr send-reportcrashes withNotImplementedErrorwhen Slack is set up with a webhook (for exampleslack.notification_webhookin~/.edr/config.yml, whichedr monitoruses) and the report goes to a bucket that returns no website URL (S3/GCS/Azure without--update-bucket-website).In that setup
SlackClient.create_clientreturns aSlackWebhookClient.send_reportuploads the report and posts the summary through the webhook. Because there is no bucket website URL, it then decides to attach the HTML file to Slack and callsSlackWebhookClient.send_report, which israise NotImplementedError. The command ends with a traceback and a non-zero exit code, even though the upload and the summary both worked.Fix
DataMonitoringReport.send_reportskips the HTML attachment when the Slack client is a webhook client, because a webhook can't upload files, and logs a warning that explains why. Token-based Slack (SlackWebClient) still sends the attachment as before.Tests
New
tests/unit/monitor/data_monitoring/report/test_data_monitoring_report.py, using aDataMonitoringReportsubclass in the style of the existingDataMonitoringAlertsMock(the warehouse, the bucket upload and the summary are stubbed; the Slack client is the real one thatcreate_clientbuilds fromConfig):send_report()returnsTrue. Onmaster(e34d853) it raisesNotImplementedErrorfromelementary/clients/slack/client.py:293.Full unit suite:
483 passed. black / isort (--profile black) / flake8 / mypy / typos are clean on the changed files.Summary by CodeRabbit