mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-08 22:38:05 -05:00
fix(event-webhook): Improve error logging with exception type and stack trace (#12202)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -134,12 +134,12 @@ async def _process_batch_operations_background(
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
'error_processing_batch_operation',
|
||||
f'error_processing_batch_operation: {type(e).__name__}: {e}',
|
||||
extra={
|
||||
'path': batch_op.path,
|
||||
'method': str(batch_op.method),
|
||||
'error': str(e),
|
||||
},
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -699,12 +699,11 @@ class TestProcessBatchOperationsBackground:
|
||||
# Should not raise exceptions
|
||||
await _process_batch_operations_background(batch_ops, 'test-api-key')
|
||||
|
||||
# Should log the error
|
||||
mock_logger.error.assert_called_once_with(
|
||||
'error_processing_batch_operation',
|
||||
extra={
|
||||
'path': 'invalid-path',
|
||||
'method': 'BatchMethod.POST',
|
||||
'error': mock_logger.error.call_args[1]['extra']['error'],
|
||||
},
|
||||
)
|
||||
# Should log the error with exception type and message in the log message
|
||||
mock_logger.error.assert_called_once()
|
||||
call_args = mock_logger.error.call_args
|
||||
log_message = call_args[0][0]
|
||||
assert log_message.startswith('error_processing_batch_operation:')
|
||||
assert call_args[1]['extra']['path'] == 'invalid-path'
|
||||
assert call_args[1]['extra']['method'] == 'BatchMethod.POST'
|
||||
assert call_args[1]['exc_info'] is True
|
||||
|
||||
Reference in New Issue
Block a user