Skip to content

fix(celery): don't report the by-design codec rejection to Sentry#3041

Merged
vpetersson merged 1 commit into
masterfrom
fix/codec-rejection-not-sentry-error
Jun 9, 2026
Merged

fix(celery): don't report the by-design codec rejection to Sentry#3041
vpetersson merged 1 commit into
masterfrom
fix/codec-rejection-not-sentry-error

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

What

The upload codec/resolution gate raises UnsupportedVideoCodecError as 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:

  • Pi 5 has no H.264 hardware-decode block, so an H.264 upload is rejected (Supported: hevc.).
  • An unknown arm64 board that never published a board_subtype can't certify any codec.

But every rejection was reaching Sentry as an unhandled Celery task error — 31+ events on ANTHIAS-1J, plus ANTHIAS-20.

Fix

List UnsupportedVideoCodecError in the video task's throws. Celery then logs it at INFO with no traceback, and sentry-sdk's CeleryIntegration skips task.throws exceptions — its _capture_exception returns early on isinstance(exc, task.throws) (verified against the pinned sentry-sdk==2.61.1). on_failure still runs, so the operator-facing error pill + recipe are unchanged.

Test

test_video_task_declares_codec_rejection_as_expected asserts the video task declares it in throws and the image task (which never raises it) does not.

🤖 Generated with Claude Code

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>
@vpetersson vpetersson requested a review from a team as a code owner June 9, 2026 06:39
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.UnsupportedVideoCodecError in normalize_video_asset’s Celery throws option 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.

@vpetersson vpetersson merged commit 5d21924 into master Jun 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants