Skip to content

fix(plugin-manager): fix TypeError breaking every plugin's scheduled update#392

Merged
ChuckBuilds merged 1 commit into
mainfrom
fix/monitored-update-static-binding
Jul 11, 2026
Merged

fix(plugin-manager): fix TypeError breaking every plugin's scheduled update#392
ChuckBuilds merged 1 commit into
mainfrom
fix/monitored-update-static-binding

Conversation

@ChuckBuilds

@ChuckBuilds ChuckBuilds commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Investigating a user report that the odds-ticker plugin doesn't update
scores or game status. Root cause: PluginManager.run_scheduled_updates()
has been throwing a TypeError on every single plugin's scheduled
update since PR #388 merged, for any deployment where resource_monitor
is set (i.e. all of them — both display_controller.py and
web_interface/app.py assign a real PluginResourceMonitor after
construction).

Root cause

if self.resource_monitor:
    def monitored_update():
        self.resource_monitor.monitor_call(plugin_id, plugin_instance.update)
    success = self.plugin_executor.execute_update(
        type('obj', (object,), {'update': monitored_update})(),
        plugin_id
    )

monitored_update is stored as a class attribute on a dynamically-built
type. Python's descriptor protocol turns a function found via class-attribute
lookup into a bound method when accessed on an instance — so
plugin_executor's plugin.update() call silently becomes
monitored_update(<synthetic instance>), but monitored_update takes zero
parameters. Every call raises:

monitored_update() takes 0 positional arguments but 1 was given

This gets caught by run_scheduled_updates's try/except and recorded as an
update failure — so no plugin's update() has succeeded since a device
picked up #388 (2026-07-09). Circuit breakers cycle through
half-open → immediate failure → reopened forever, and every plugin's data
(scores, odds, prices, etc.) goes stale at whatever was last fetched before
the upgrade.

Confirmed live on a running instance — odds-ticker (and stock-news,
ledmatrix-stocks, baseball-scoreboard, ledmatrix-leaderboard,
of-the-day) failing this exact way on every 5-minute circuit-breaker retry,
matching the reported symptom precisely.

The buggy line itself dates back to 2025-12-27, but self.resource_monitor
was None (dormant) until #388 wired it up — so this is a very recent
regression despite the code being old.

Fix

types.SimpleNamespace(update=monitored_update) instead of a dynamic class.
SimpleNamespace stores attributes on the instance, so attribute lookup
returns the plain function unchanged — it never goes through the
class-attribute descriptor protocol that injects an implicit self.

Test plan

  • Added test_run_scheduled_updates_calls_update_with_resource_monitor using
    a real PluginResourceMonitor (not a mock of it), so the test actually
    exercises the descriptor-binding behavior that caused this.
  • Verified the new test fails with the exact reported error
    (monitored_update() takes 0 positional arguments but 1 was given)
    against the pre-fix code, and passes against the fix.
  • Full test_plugin_system.py suite: all passing tests still pass (the one
    pre-existing failure, TestPluginHealth::test_circuit_breaker, is a known
    stale-mock issue unrelated to this change — same one PR fix(plugins): replace dependency marker files with a real satisfaction check #390's test plan
    already called out).
  • Full CI plugin-safety suite (test_harness.py, test_visual_rendering.py,
    test_plugin_matrix.py): 52 passed, 2 pre-existing skips.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed scheduled plugin updates when resource monitoring is enabled.
    • Ensured plugin updates execute correctly, record the latest update, and preserve the plugin’s enabled state.
  • Tests

    • Added regression coverage for resource-monitored scheduled updates.

…update

run_scheduled_updates()'s resource-monitor branch wrapped the update call
in a closure stored as a *class* attribute on a dynamically-built type
(type('obj', (object,), {'update': monitored_update})()). The descriptor
protocol turns a function found via class-attribute lookup into a bound
method on instance access, silently prepending the synthetic instance as
an implicit first argument -- but monitored_update() takes none, so every
call raised "monitored_update() takes 0 positional arguments but 1 was
given", was caught by run_scheduled_updates' try/except, and recorded as
an update failure.

self.resource_monitor is None by default and was dormant until PR #388
("activate dormant plugin health/metrics subsystem") wired it up in both
display_controller.py and web_interface/app.py -- meaning this bug went
live in every real deployment as of that merge (2026-07-09) despite the
buggy line itself dating back to 2025-12-27. In practice this means no
plugin's update() has succeeded since upgrading past #388: circuit
breakers cycle through half-open -> immediate failure -> reopened every
health-check interval forever, and all plugin data (scores, odds, prices,
etc.) goes stale from whatever was last fetched before the upgrade.
Confirmed live on a running instance: odds-ticker (and stock-news,
ledmatrix-stocks, baseball-scoreboard, ledmatrix-leaderboard, of-the-day)
failing this exact way every 5-minute circuit-breaker retry.

Fixed by using types.SimpleNamespace(update=monitored_update) instead of
a dynamic class: SimpleNamespace stores attributes on the instance
itself, so attribute lookup returns the plain function unchanged --
never routed through the class-attribute descriptor protocol that
injects an implicit self.

Added test_run_scheduled_updates_calls_update_with_resource_monitor to
test/test_plugin_system.py using a real PluginResourceMonitor (not a
mock of it), so the test exercises the actual descriptor-binding
behavior that caused this. Verified the test fails with the exact
reported error against the pre-fix code and passes against the fix.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4871163c-4e8f-42e8-b556-ea7a27bb1194

📥 Commits

Reviewing files that changed from the base of the PR and between 978a03b and f204675.

📒 Files selected for processing (2)
  • src/plugin_system/plugin_manager.py
  • test/test_plugin_system.py

📝 Walkthrough

Walkthrough

PluginManager now wraps resource-monitored updates with types.SimpleNamespace, avoiding bound-method argument mismatches. A regression test verifies update invocation, last-update tracking, and state preservation.

Changes

Scheduled update execution

Layer / File(s) Summary
Monitored update wrapper and regression test
src/plugin_system/plugin_manager.py, test/test_plugin_system.py
The resource-monitor path passes a SimpleNamespace wrapper to PluginExecutor.execute_update; tests verify the enabled plugin updates successfully, records its last update, and remains enabled.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: a TypeError in plugin-manager scheduled updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/monitored-update-static-binding

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.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@ChuckBuilds ChuckBuilds merged commit aab0e9a into main Jul 11, 2026
8 checks passed
@ChuckBuilds ChuckBuilds deleted the fix/monitored-update-static-binding branch July 11, 2026 12:54
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.

1 participant