fix(xai): recover legacy encrypted replay failures (#62420)

This commit is contained in:
Teknium 2026-07-11 03:51:38 -07:00 committed by GitHub
parent c7619773e7
commit 91d05b982d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View file

@ -1147,6 +1147,7 @@ def _classify_400(
"encrypted content for item" in error_msg
and "could not be verified" in error_msg
)
or "could not decrypt the provided encrypted_content" in error_msg
):
return result_fn(
FailoverReason.invalid_encrypted_content,

View file

@ -841,6 +841,26 @@ class TestClassifyApiError:
assert result.retryable is True
assert result.should_fallback is False
def test_xai_invalid_encrypted_content_wording_uses_replay_recovery(self):
e = MockAPIError(
"Error code: 400 - Could not decrypt the provided encrypted_content. "
"Ensure the value is the unmodified encrypted_content from a previous response.",
status_code=400,
body={
"code": "Client specified an invalid argument",
"error": (
"Could not decrypt the provided encrypted_content. Ensure the value "
"is the unmodified encrypted_content from a previous response."
),
},
)
result = classify_api_error(e, provider="xai-oauth", model="grok-4.3")
assert result.reason == FailoverReason.invalid_encrypted_content
assert result.retryable is True
assert result.should_fallback is False
def test_invalid_encrypted_content_broad_message_match_does_not_catch_generic_parse_error(self):
message = "Encrypted content could not be decrypted or parsed."
e = MockAPIError(