Skip to content

fix(gateway): wrap cron helpers with staticmethod to prevent self-binding#5299

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-3d0a599a
Apr 5, 2026
Merged

fix(gateway): wrap cron helpers with staticmethod to prevent self-binding#5299
teknium1 merged 1 commit intomainfrom
hermes/hermes-3d0a599a

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

@teknium1 teknium1 commented Apr 5, 2026

Summary

Salvage of PR #5167 by @MichaelWDanko with an improved fix approach.

Bug: All 8 cron API endpoints in the API server crash with TypeError at runtime. Plain functions imported as class attributes (from cron.jobs import list_jobs as _cron_list) become bound methods when called via self._cron_*(), injecting self as the first positional argument.

Original PR's fix: Changed all 8 call sites to type(self)._cron_*().

This PR's fix: Wraps each import with staticmethod() at the declaration site. This prevents the descriptor binding while keeping all call sites unchanged — cleaner and more idiomatic.

Changes

  • gateway/platforms/api_server.py — 8 staticmethod() wrappers added after the cron import block
  • tests/gateway/test_api_server_jobs.py — 3 regression tests (pause, list, update) verifying no self injection with plain-function patches wrapped in staticmethod()

Test results

  • test_api_server_jobs.py: 35 passed (32 existing + 3 new)
  • test_api_server.py + test_api_server_jobs.py: 129 passed, 0 failures

Closes #5167. Contributor authorship preserved.

…ding

Plain functions imported as class attributes in APIServerAdapter get
auto-bound as methods via Python's descriptor protocol.  Every
self._cron_*() call injected self as the first positional argument,
causing TypeError on all 8 cron API endpoints at runtime.

Wrap each import with staticmethod() so self._cron_*() calls dispatch
correctly without modifying any call sites.

Co-authored-by: teknium <teknium@nousresearch.com>
@teknium1 teknium1 merged commit c6793d6 into main Apr 5, 2026
3 of 4 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