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:
Graham Neubig
2025-12-29 18:09:20 -05:00
committed by GitHub
parent c3f51d9dbe
commit 4dec38c7ce
2 changed files with 10 additions and 11 deletions

View File

@@ -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,
)

View File

@@ -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