Skip to content

fix: guard media template seek/re-entry, add capability flags - #430

Draft
JarbasAl wants to merge 1 commit into
devfrom
fix/media-template-guards
Draft

fix: guard media template seek/re-entry, add capability flags#430
JarbasAl wants to merge 1 commit into
devfrom
fix/media-template-guards

Conversation

@JarbasAl

Copy link
Copy Markdown
Member

🤖 Auto-generated by Claude Fable 5 (claude-fable-5) via Claude Code — NOT human-reviewed. Verify before acting.

This fixes three small defects in ovos_plugin_manager/templates/media.py, the base class OCP media backends subclass.

seek_forward and seek_backward called self.get_track_position() + ms with no guard on the return value. A backend that legitimately has no track position yet (nothing loaded, a live stream, a backend still starting up) returns None, and the arithmetic raises TypeError. Both methods now check for None, log at debug level, and return without seeking.

ocp_start re-emitted PLAYER.PLAYING and MEDIA.LOADED_MEDIA and called play() again every time it was invoked, even if playback was already active. A caller that invokes ocp_start twice in a row — which does happen given the eventual consistency of bus messaging — would double-start playback. ocp_start is now idempotent: a _ocp_playing flag tracks whether playback is already active, and a re-entrant call is a no-op until ocp_stop, ocp_error, or a new load_track resets it. The AudioPlayerBackend/VideoPlayerBackend/WebPlayerBackend subclasses, which each emit an extra track-state message on top of the base call, were updated the same way so they don't double-emit either.

MediaBackend gains two class attributes, supports_seek and supports_pause, both defaulting to True. They're purely additive — existing plugins are unaffected — and let backends that genuinely can't seek or pause (a live stream, for instance) declare that so callers can check before calling.

ovos-media currently guards against all three of these at every call site that touches a backend. None of that guarding is removed here; this just makes the template itself correct, so those call-site guards become redundant rather than load-bearing, and can be simplified later without changing behavior.

Tests: added adversarial cases to test/unittests/test_media_templates.py covering a None position on both seek directions, re-entrant ocp_start (base class and AudioPlayerBackend), ocp_start resuming correctly after ocp_stop and after a new load_track, and the new capability-flag defaults. Every new test was confirmed to fail against the unfixed template (reverted via patch) and pass after the fix. Full existing suite: 969 passed, 3 pre-existing failures in test_deprecation_noise.py (unrelated — deprecation-warning counts for solvers/OpenVoiceOSPlugin, untouched by this change) unchanged before and after; test_hardware.py/test_led_animations.py skipped, missing the optional ovos-hardware-helpers dependency, also unrelated.

seek_forward/seek_backward crashed with TypeError when a backend's
get_track_position() returned None; they now log and no-op instead.
ocp_start is now idempotent while playback is already active, so a
re-entrant call no longer double-emits LOADED_MEDIA/PLAYING or calls
play() twice. MediaBackend also gains supports_seek and supports_pause
class attributes (both default True) so consumers can check backend
capability before calling seek/pause.
@github-actions github-actions Bot added the fix label Aug 16, 2026
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ff9255ba-02e7-47f3-8345-784b285a689b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Checking back in with the latest test results. 📡

I've aggregated the results of the automated checks for this PR below.

🏷️ Release Preview

The draft for the big day is ready for review. 📝

Current: 2.11.1a2Next: 2.11.2a1

Signal Value
Label (none)
PR title fix: guard media template seek/re-entry, add capability flags
Bump build

✅ PR title follows conventional commit format.


🚀 Release Channel Compatibility

Predicted next version: 2.11.2a1

Channel Status Note Current Constraint
Stable Too new (must be <0.10.0) ovos-plugin-manager>=0.9.0,<0.10.0
Testing Compatible ovos-plugin-manager>=1.0.3,<3.0.0
Alpha Compatible ovos-plugin-manager>=2.11.1a2

⚖️ License Check

Ensuring our licenses allow for commercial use. 🏢

✅ No license violations found.

Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed.

📋 Repo Health

Checking the repo's mental health (aka developer happiness). 😊

✅ All required files present.

Latest Version: 2.11.1a2

ovos_plugin_manager/version.py — Version file
README.md — README
LICENSE — License file
pyproject.toml — pyproject.toml
⚠️ setup.py — setup.py
CHANGELOG.md — Changelog
ovos_plugin_manager/version.py has valid version block markers

🔍 Lint

The latest check report is now ready. 📝

ruff: issues found — see job log

🔒 Security (pip-audit)

Ensuring our certificates are valid and trustworthy. 📜

✅ No known vulnerabilities found (65 packages scanned).

📊 Coverage

How much of the logic is under the microscope? 🔬

82.8% total coverage

⚠️ Some tests failed — coverage figures may be incomplete.

Files below 80% coverage (23 files)
File Coverage Missing lines
ovos_plugin_manager/utils/audio.py 27.0% 65
ovos_plugin_manager/templates/embeddings.py 27.5% 187
ovos_plugin_manager/hardware/__init__.py 31.6% 13
ovos_plugin_manager/__init__.py 33.3% 4
ovos_plugin_manager/templates/gui.py 39.0% 25
ovos_plugin_manager/audio.py 40.5% 22
ovos_plugin_manager/templates/language.py 58.0% 21
ovos_plugin_manager/audio2ipa.py 58.1% 13
ovos_plugin_manager/gui.py 62.5% 15
ovos_plugin_manager/postag.py 63.0% 17
ovos_plugin_manager/segmentation.py 63.0% 17
ovos_plugin_manager/tokenization.py 63.0% 17
ovos_plugin_manager/templates/solvers.py 68.7% 82
ovos_plugin_manager/coreference.py 69.2% 16
ovos_plugin_manager/plugin_entry.py 69.5% 46
ovos_plugin_manager/templates/ocp.py 72.2% 5
ovos_plugin_manager/templates/segmentation.py 73.7% 5
ovos_plugin_manager/templates/audio2ipa.py 75.0% 3
ovos_plugin_manager/templates/postag.py 75.0% 5
ovos_plugin_manager/media_provider.py 75.7% 9
ovos_plugin_manager/templates/hotwords.py 77.4% 7
ovos_plugin_manager/persona.py 77.8% 2
ovos_plugin_manager/templates/keywords.py 78.9% 4

Full report: download the coverage-report artifact.

🔨 Build Tests

Testing the integrity of the build artifacts. 🏺

Python Build Install Tests
3.10 ⚠️
3.11 ⚠️
3.12 ⚠️
3.13 ⚠️
3.14 ⚠️

❌ 3.10: Install OK, tests failed
❌ 3.11: Install OK, tests failed
❌ 3.12: Install OK, tests failed
❌ 3.13: Install OK, tests failed
❌ 3.14: Install OK, tests failed
Check job logs for details.


Your digital assistant in the world of OVOS 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant