From 1ec4a34dcde82d38080ddb2b4f439c9244e47937 Mon Sep 17 00:00:00 2001 From: elmatadorgh Date: Mon, 20 Apr 2026 02:12:38 -0700 Subject: [PATCH] test(error_classifier): broaden non-string message type coverage Adds regression tests for list-typed, int-typed, and None-typed message fields on top of the dict-typed coverage from #11496. Guards against other provider quirks beyond the original Pydantic validation case. Credit to @elmatadorgh (#11264) for the broader type coverage idea. --- tests/agent/test_error_classifier.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/agent/test_error_classifier.py b/tests/agent/test_error_classifier.py index dd74249b1..be4775a4d 100644 --- a/tests/agent/test_error_classifier.py +++ b/tests/agent/test_error_classifier.py @@ -919,3 +919,27 @@ class TestAdversarialEdgeCases: ) result = classify_api_error(e) assert result.reason == FailoverReason.format_error + + # Broader non-string type guards — defense against other provider quirks. + + def test_list_message_no_crash(self): + """Some providers return message as a list of error entries.""" + e = MockAPIError( + "validation", + status_code=400, + body={"message": [{"msg": "field required"}]}, + ) + result = classify_api_error(e) + assert result is not None + + def test_int_message_no_crash(self): + """Any non-string type must be coerced safely.""" + e = MockAPIError("server error", status_code=500, body={"message": 42}) + result = classify_api_error(e) + assert result is not None + + def test_none_message_still_works(self): + """Regression: None fallback (the 'or \"\"' path) must still work.""" + e = MockAPIError("server error", status_code=500, body={"message": None}) + result = classify_api_error(e) + assert result is not None