Problem Description
In ami/ml/tasks.py, the process_source_images_async function catches Job.DoesNotExist exceptions but doesn't reset job_id to None. This means the invalid job_id is passed to downstream functions (process_images() and save_results()), which could cause errors.
Additionally, the exception handler uses logger.error() instead of logger.exception(), which means the full traceback is not captured for debugging.
Context
Expected Behavior
When a Job.DoesNotExist exception occurs:
- The
job_id variable should be set to None to prevent passing an invalid ID downstream
- The full exception traceback should be logged using
logger.exception() for debugging
Requested by: @mihow