mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
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.
This commit is contained in:
parent
b869bf206c
commit
1ec4a34dcd
1 changed files with 24 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue