Skip to content

auto-triage: catch TypeError from malformed RAST server error response#3

Draft
jplfaria wants to merge 2 commits into
mainfrom
auto-triage/issue-19-rast-server-error-str
Draft

auto-triage: catch TypeError from malformed RAST server error response#3
jplfaria wants to merge 2 commits into
mainfrom
auto-triage/issue-19-rast-server-error-str

Conversation

@jplfaria

Copy link
Copy Markdown
Contributor

Summary

Fixes ModelSEED/modelseed-api-ops#19

Root cause

When the RAST annotation server (tutorial.theseed.org) returns an error response where err["error"] is a plain string instead of the expected {"code":..., "message":...} dict, the rpcclient.py line:

raise ServerError(**err["error"])  # line 75

raises TypeError: ServerError() argument after ** must be a mapping, not str.

This TypeError escapes genome_annotator.py's except Exception as exc: block because:

  • The except block does catch it
  • But is_transient is False (no HTTP status codes in the TypeError message)
  • So it re-raises the raw TypeError, giving Celery workers a misleading internal Python error

Fix

Add a except TypeError as exc: handler before the general except Exception in annotate_fasta()'s retry loop. It converts the raw TypeError into a descriptive RuntimeError so the Celery failure log and job error field show a meaningful message.

Files changed

  • src/modelseed_api/services/genome_annotator.py: Add TypeError handler
  • tests/unit/test_genome_annotator.py: Add TestAnnotateFastaTypeErrorHandling regression test

Test plan

  • Unit test test_rpc_typeerror_wraps_to_runtimeerror passes (mocks RPCClient to raise TypeError, verifies RuntimeError with "malformed error response" is raised)
  • Existing genome annotator unit tests still pass

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