logging
This commit is contained in:
@@ -961,15 +961,30 @@ class IntegrationSettingsViewSet(viewsets.ViewSet):
|
||||
'meta': response_meta
|
||||
})
|
||||
elif task_state == 'FAILURE':
|
||||
# Try to get error from task.info meta first (this is where run_ai_task sets it)
|
||||
if not error_message and isinstance(task_info, dict):
|
||||
error_message = task_info.get('error') or task_info.get('message', '')
|
||||
error_type = task_info.get('error_type', 'UnknownError')
|
||||
# Also check if message contains error info
|
||||
if not error_message and 'message' in task_info:
|
||||
msg = task_info.get('message', '')
|
||||
if msg and 'Error:' in msg:
|
||||
error_message = msg.replace('Error: ', '')
|
||||
|
||||
# Use extracted error_message if available, otherwise try to get from error_info
|
||||
if not error_message:
|
||||
error_info = task_info
|
||||
if isinstance(error_info, Exception):
|
||||
error_message = str(error_info)
|
||||
elif isinstance(error_info, dict):
|
||||
error_message = error_info.get('error', str(error_info))
|
||||
else:
|
||||
error_message = str(error_info) if error_info else 'Task failed'
|
||||
error_message = error_info.get('error') or error_info.get('message', '') or str(error_info)
|
||||
elif error_info:
|
||||
error_message = str(error_info)
|
||||
|
||||
# Final fallback - ensure we always have an error message
|
||||
if not error_message or error_message.strip() == '':
|
||||
error_message = f'Task execution failed - check Celery worker logs for task {task_id}'
|
||||
error_type = 'ExecutionError'
|
||||
|
||||
response_meta = {
|
||||
'error': error_message,
|
||||
|
||||
Reference in New Issue
Block a user