fix(celery): don't report the by-design codec rejection to Sentry#3041
Merged
Conversation
The upload codec/resolution gate raises ``UnsupportedVideoCodecError`` as a deliberate, operator-facing rejection — it's surfaced in the UI as a "Failed" pill plus a copy-pasteable ffmpeg re-encode recipe via ``_NormalizeAssetTask.on_failure``. It's an expected outcome (e.g. Pi 5 has no H.264 HW decode block, an unknown arm64 board can't certify any codec), not a fault, so it shouldn't reach Sentry — but every rejection was landing there as an unhandled task error (Sentry ANTHIAS-1J, ANTHIAS-20). List it in the video task's ``throws``: Celery then logs it at INFO without a traceback, and sentry-sdk's CeleryIntegration skips ``task.throws`` exceptions (``_capture_exception`` returns early on ``isinstance(exc, task.throws)``), so the gate stops flooding Sentry. ``on_failure`` still runs, so the operator-facing error pill and recipe are unchanged. Regression test asserts the video task declares it in ``throws`` and the image task (which never raises it) does not. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
There was a problem hiding this comment.
Pull request overview
This PR updates the video normalization Celery task configuration so that deliberate upload rejections (UnsupportedVideoCodecError) are treated as expected task outcomes rather than “errors,” preventing these by-design rejections from being reported to Sentry while preserving the operator-facing failure UX handled by _NormalizeAssetTask.on_failure.
Changes:
- Declare
processing.UnsupportedVideoCodecErrorinnormalize_video_asset’s Celerythrowsoption to suppress traceback/error-level logging and skip Sentry capture for this expected exception. - Add a unit test asserting the video task includes this exception in
throws, and the image task does not.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/anthias_server/celery_tasks.py |
Adds throws=(processing.UnsupportedVideoCodecError,) to normalize_video_asset to prevent expected codec gate rejections from being reported to Sentry. |
tests/test_processing.py |
Adds a regression test verifying throws includes the codec rejection for the video task only. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
The upload codec/resolution gate raises
UnsupportedVideoCodecErroras a deliberate, operator-facing rejection — surfaced in the UI as a "Failed" pill plus a copy-pasteable ffmpeg re-encode recipe (via_NormalizeAssetTask.on_failure). It's an expected outcome, not a fault:Supported: hevc.).board_subtypecan't certify any codec.But every rejection was reaching Sentry as an unhandled Celery task error — 31+ events on
ANTHIAS-1J, plusANTHIAS-20.Fix
List
UnsupportedVideoCodecErrorin the video task'sthrows. Celery then logs it at INFO with no traceback, and sentry-sdk'sCeleryIntegrationskipstask.throwsexceptions — its_capture_exceptionreturns early onisinstance(exc, task.throws)(verified against the pinnedsentry-sdk==2.61.1).on_failurestill runs, so the operator-facing error pill + recipe are unchanged.Test
test_video_task_declares_codec_rejection_as_expectedasserts the video task declares it inthrowsand the image task (which never raises it) does not.🤖 Generated with Claude Code