Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 8, 2025

Problem

The system was using generic ValueError to signal job deletion in the user-facing API, which is too generic and might hide other errors. Additionally, RDSJobQueue.handle_timeouts was not handling deletion errors gracefully, causing crashes when jobs were deleted by users.

Solution

This PR introduces a specific JobDeletedException for job deletion scenarios and updates all relevant code to handle it gracefully.

Key Changes

  1. New Exception Class: Created JobDeletedException in workerfacing_api/exceptions.py with job ID tracking and descriptive error messages.

  2. Updated Error Handling:

    • job_tracking.update_job now raises JobDeletedException instead of ValueError on 404 responses
    • RDSJobQueue._update_job_status catches and re-raises the specific exception
    • RDSJobQueue.handle_timeouts gracefully handles deletion errors by skipping status updates
    • RDSJobQueue.pop gracefully handles deletion errors by returning False
    • API endpoints catch the specific exception maintaining 404 behavior
  3. Improved Robustness: The timeout handling mechanism now continues processing other jobs even when some jobs are deleted, preventing system crashes.

Example

Before:

# Generic ValueError could hide other issues
except ValueError as e:
    # Could be job deletion OR other validation error
    pass

After:

# Specific exception for job deletion
except JobDeletedException:
    # Definitely a job deletion - handle gracefully
    pass

Testing

  • Added comprehensive unit tests for the new exception handling
  • Verified existing queue functionality remains intact
  • Confirmed graceful handling of deletion scenarios in timeout processing

This change improves error specificity and system reliability while maintaining backward compatibility.

Fixes #67.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cognito-idp.eu-central-1.amazonaws.com
    • Triggering command: /home/REDACTED/work/DECODE_Cloud_WorkerAPI/DECODE_Cloud_WorkerAPI/.venv/bin/python -m pytest tests/integration/endpoints/test_jobs.py::TestJobs::test_put_job_status_canceled -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] BUG: 404 when job in queue was deleted in user-facing API Fix job deletion error handling with specific JobDeletedException Jul 8, 2025
Copilot AI requested a review from nolan1999 July 8, 2025 22:21
Copy link
Contributor Author

Copilot AI commented Jul 8, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • install.python-poetry.org
    • Triggering command: curl -sSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from nolan1999 July 8, 2025 22:58
@github-actions
Copy link

github-actions bot commented Jul 9, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
workerfacing_api
   __init__.py00100% 
   dependencies.py481667%32, 48–53, 72–90
   exceptions.py40100% 
   main.py281161%36–45, 50
   settings.py28582%8–11, 30
   tags.py10100% 
workerfacing_api/core
   __init__.py00100% 
   filesystem.py73593%17, 23, 27, 33, 108
   queue.py2922890%77, 82, 87, 101, 106, 141, 173, 247–248, 275–276, 282, 299–300, 358–362, 367, 401, 461–463, 482, 556–558, 568–570
workerfacing_api/crud
   __init__.py00100% 
   job_tracking.py11191%26
workerfacing_api/endpoints
   __init__.py00100% 
   access.py9189%24
   files.py23196%24
   jobs.py671282%73–74, 95–96, 149–150, 154–155, 175–176, 180–181
   jobs_post.py90100% 
workerfacing_api/schemas
   __init__.py00100% 
   files.py60100% 
   queue_jobs.py520100% 
   rds_models.py320100% 
TOTAL6838088% 

Tests Skipped Failures Errors Time
123 0 💤 0 ❌ 0 🔥 16m 21s ⏱️

Copy link
Contributor Author

Copilot AI commented Jul 9, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • install.python-poetry.org
    • Triggering command: curl -sSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from nolan1999 July 9, 2025 12:54
Copy link
Member

@nolan1999 nolan1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poetry run ruff format --check . is failing. Please correct the formatting (you can run poetry run ruff format --fix . .

Copilot AI and others added 8 commits July 11, 2025 13:41
Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
…ary tests

Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
…test_job_tracking.py

Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
Co-authored-by: nolan1999 <54246789+nolan1999@users.noreply.github.com>
@nolan1999 nolan1999 marked this pull request as ready for review July 11, 2025 21:46
@nolan1999 nolan1999 merged commit c4a93da into main Jul 11, 2025
2 checks passed
@nolan1999 nolan1999 deleted the copilot/fix-67-2 branch July 11, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correct behavior when job was deleted on user-facing API side

2 participants