diff --git a/src/modelseed_api/services/genome_annotator.py b/src/modelseed_api/services/genome_annotator.py index ce07acd..594b52c 100644 --- a/src/modelseed_api/services/genome_annotator.py +++ b/src/modelseed_api/services/genome_annotator.py @@ -183,6 +183,8 @@ def annotate_fasta( [genome_dict, {"stages": stages}], ) break + except TypeError as exc: + raise RuntimeError("RAST malformed error response (expected dict, got str). Original: " + str(exc)) from exc except Exception as exc: msg = str(exc) is_transient = any(code in msg for code in _TRANSIENT_5XX) diff --git a/tests/unit/test_genome_annotator.py b/tests/unit/test_genome_annotator.py index 558c518..7a1e181 100644 --- a/tests/unit/test_genome_annotator.py +++ b/tests/unit/test_genome_annotator.py @@ -178,3 +178,20 @@ def call(self, method, params): with pytest.raises(ValueError, match="no.*functional roles"): annotate_fasta(">p1\nMKKLVAVLIVSLAVALSALAVA") + + + +class TestAnnotateFastaTypeErrorHandling: + def test_rpc_typeerror_wraps_to_runtimeerror(self, monkeypatch): + class BadErrorClient: + def __init__(self, url, timeout=600): + pass + def call(self, method, params): + raise TypeError( + "argument after ** must be a mapping, not str" + ) + monkeypatch.setattr( + "modelseed_api.services.genome_annotator.RPCClient", BadErrorClient, + ) + with pytest.raises(RuntimeError, match="malformed error response"): + annotate_fasta(">p1\nMKKLVAVLIVSLAVALSALAVA") \ No newline at end of file