fix(plugin-manager): fix TypeError breaking every plugin's scheduled update#392
Conversation
…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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesScheduled update execution
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
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.
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
TypeErroron every single plugin's scheduledupdate since PR #388 merged, for any deployment where
resource_monitoris set (i.e. all of them — both
display_controller.pyandweb_interface/app.pyassign a realPluginResourceMonitorafterconstruction).
Root cause
monitored_updateis stored as a class attribute on a dynamically-builttype. Python's descriptor protocol turns a function found via class-attribute
lookup into a bound method when accessed on an instance — so
plugin_executor'splugin.update()call silently becomesmonitored_update(<synthetic instance>), butmonitored_updatetakes zeroparameters. Every call raises:
This gets caught by
run_scheduled_updates's try/except and recorded as anupdate failure — so no plugin's
update()has succeeded since a devicepicked 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(andstock-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_monitorwas
None(dormant) until #388 wired it up — so this is a very recentregression despite the code being old.
Fix
types.SimpleNamespace(update=monitored_update)instead of a dynamic class.SimpleNamespacestores attributes on the instance, so attribute lookupreturns the plain function unchanged — it never goes through the
class-attribute descriptor protocol that injects an implicit
self.Test plan
test_run_scheduled_updates_calls_update_with_resource_monitorusinga real
PluginResourceMonitor(not a mock of it), so the test actuallyexercises the descriptor-binding behavior that caused this.
(
monitored_update() takes 0 positional arguments but 1 was given)against the pre-fix code, and passes against the fix.
test_plugin_system.pysuite: all passing tests still pass (the onepre-existing failure,
TestPluginHealth::test_circuit_breaker, is a knownstale-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).
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
Tests