Skip to content

[codex] Guard optional audio codec imports#7928

Open
tianmind-studio wants to merge 6 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-opus-import-guard
Open

[codex] Guard optional audio codec imports#7928
tianmind-studio wants to merge 6 commits into
BasedHardware:mainfrom
tianmind-studio:codex/windows-opus-import-guard

Conversation

@tianmind-studio

@tianmind-studio tianmind-studio commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Defer missing native Opus failures in utils.other.storage and routers.sync until code actually needs Opus encode/decode.
  • Guard routers.transcribe Opus and LC3 imports so missing optional codec libraries do not block non-codec module import paths.
  • Validate malformed Opus packet structure before creating the native decoder.
  • Add Windows-focused regression coverage for missing native opuslib, and skip storage tests that require real libopus when the native library is unavailable.

Root cause

On Windows, installing the opuslib Python package is not enough if the native libopus DLL is missing. Importing opuslib can raise during module import, which previously prevented backend modules such as utils.other.storage and routers.sync from loading even when the current path did not need Opus processing.

Validation

  • python -m pytest backend\tests\unit\test_optional_audio_codecs.py backend\tests\unit\test_storage_opus_encoding.py -q --tb=short -> 38 passed, 11 skipped
  • python -m pytest backend\tests\unit\test_sync_opus_decode.py -q --tb=short -> 21 passed
  • python -m py_compile backend\utils\other\storage.py backend\routers\sync.py backend\routers\transcribe.py backend\tests\unit\test_optional_audio_codecs.py backend\tests\unit\test_storage_opus_encoding.py
  • python -m black --check --line-length 120 --skip-string-normalization backend\utils\other\storage.py backend\routers\sync.py backend\routers\transcribe.py backend\tests\unit\test_optional_audio_codecs.py backend\tests\unit\test_storage_opus_encoding.py
  • git diff --check
  • bash -n backend/test.sh
  • bash scripts/pre-commit
  • GitHub Actions Lint Check run 4999 -> success

Note

backend/test-preflight.sh still fails on this Windows checkout because origin/main can select the WindowsApps python3 alias instead of the active venv; that separate preflight issue is already covered by #7926.

Related: #7628

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Backend hardening (guard optional audio codec imports; larger diff) — approve only per policy.

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