#!/usr/bin/env python3
"""
Debug test: Analyze the actual error message to understand why pattern matching fails.
"""
def debug_error_pattern():
"""Debug the error message pattern matching."""
# This is the actual error message we received:
error_message = "NotFoundError(404, 'index_not_found_exception', 'no such index [definitely_nonexistent_index_test_12345]', definitely_nonexistent_index_test_12345, index_or_alias)"
print("π ERROR MESSAGE ANALYSIS")
print("=" * 50)
print(f"Original error: {error_message}")
print()
error_str = str(error_message).lower()
print(f"Lowercase error: {error_str}")
print()
# Test each pattern condition
print("π PATTERN MATCHING TESTS:")
print("-" * 30)
# Test individual conditions
has_connection = "connection" in error_str or "refused" in error_str
print(f"Connection error: {'β
' if has_connection else 'β'} - {'connection' in error_str} or {'refused' in error_str}")
has_index_not_found = "index" in error_str and "not found" in error_str
print(f"Index not found: {'β
' if has_index_not_found else 'β'} - {'index' in error_str} and {'not found' in error_str}")
has_index_exception = "index_not_found_exception" in error_str
print(f"Index exception: {'β
' if has_index_exception else 'β'} - {'index_not_found_exception' in error_str}")
has_no_such_index = "no such index" in error_str
print(f"No such index: {'β
' if has_no_such_index else 'β'} - {'no such index' in error_str}")
# Test the combined condition
combined_condition = ("index" in error_str and "not found" in error_str) or "index_not_found_exception" in error_str or "no such index" in error_str
print(f"Combined condition: {'β
' if combined_condition else 'β'}")
print()
print("π§ RECOMMENDED FIX:")
if has_index_exception or has_no_such_index:
print("β
Pattern should match! The error contains the expected patterns.")
print("π Issue might be in the order of conditions or logic flow.")
else:
print("β Pattern doesn't match. Need to add new patterns.")
print(f"π Consider adding pattern for: {error_str}")
if __name__ == "__main__":
debug_error_pattern()