Skip to content

refactor(gateway): share error-text blob between not_found classifiers - #248

Merged
hashbender merged 1 commit into
mainfrom
mirror/pr-56241
Jul 1, 2026
Merged

refactor(gateway): share error-text blob between not_found classifiers#248
hashbender merged 1 commit into
mainfrom
mirror/pr-56241

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Follow-up to NousResearch#55780 / NousResearch#56225 (dead-target not_found blast-radius fix, merged).

Why

classify_send_error and is_chat_level_not_found each build a lowercased error blob to substring-match against — but divergently: classify_send_error appends the exception class name (exc.__class__.__name__), while is_chat_level_not_found appends only str(exc). A caller passing exc= to both could get inconsistent answers on the same failure. The two functions' signatures also had swapped positional order ((exc, error_text) vs (error_text, exc)), an easy footgun.

Surfaced by the hermes-pr-review Phase 2c structured review of NousResearch#56225; the merge landed the base fix before this follow-up could ride along, so it's a standalone follow-up.

Changes

  • Extract _error_blob(exc, error_text) as the single source of truth both classifiers use (includes str(exc) when non-empty + the class name; skips an empty str(exc) so no stray leading space).
  • Align is_chat_level_not_found to (exc, error_text), matching classify_send_error; update the sole caller (gateway/delivery.py) and the three tests to keyword form.
  • Add a regression guard asserting _error_blob keeps the class name (mutation-verified: removing the class-name append fails the test).

Tests

pytest tests/gateway/test_dead_targets.py -q
26 passed

No behavior change to the classifier's current call sites (they pass error_text= only).


Mirror-of: NousResearch#56241
NousResearch#56241

@tenki-reviewer

tenki-reviewer Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Complete
No issues found!

Risk: 🟢 Low (12/100) — no findings · 90 LOC across 3 files


Minor refactoring in the gateway delivery pipeline: argument ordering change in BasePlatformAdapter and corresponding callers, with a new is_chat_level_not_found helper on DeliveryTarget. No bugs or regressions detected.

Files Reviewed (3 files)
gateway/delivery.py
gateway/platforms/base.py
tests/gateway/test_dead_targets.py

@hashbender
hashbender merged commit 0a63d63 into main Jul 1, 2026
3 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.

1 participant