Skip to content

[core] fix dataclass.asdict with None in dashboard list_jobs api - #61033

Merged
MengjinYan merged 1 commit into
ray-project:masterfrom
rueian:fix-dashboard-asdict
Feb 23, 2026
Merged

MengjinYan merged 1 commit into
ray-project:masterfrom
rueian:fix-dashboard-asdict

Conversation

@rueian

@rueian rueian commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

The /api/jobs/ endpoint in the dashboard will:

  1. List all the job keys in the KV.
  2. Get each job info by key.

But it doesn't expect any jobs to be deleted during these 2 steps, and if that happens, the api will fail and throw an TypeError exception because the deleted job will result in a None in the second step. For example:

Traceback (most recent call last):
  File "/home/ray/anaconda3/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 510, in _handle_request
    resp = await request_handler(request)
  File "/home/ray/anaconda3/lib/python3.10/site-packages/aiohttp/web_app.py", line 569, in _handle
    return await handler(request)
  File "/home/ray/anaconda3/lib/python3.10/site-packages/ray/dashboard/modules/job/job_head.py", line 514, in list_jobs
    submission_jobs = [
  File "/home/ray/anaconda3/lib/python3.10/site-packages/ray/dashboard/modules/job/job_head.py", line 516, in <listcomp>
    **dataclasses.asdict(job),
  File "/home/ray/anaconda3/lib/python3.10/dataclasses.py", line 1237, in asdict
    raise TypeError("asdict() should be called on dataclass instances")
TypeError: asdict() should be called on dataclass instances

This PR fixes this by excluding None jobs.

Related issues

Part of anyscale#700

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@rueian rueian added go add ONLY when ready to merge, run all tests core Issues that should be addressed in Ray Core labels Feb 12, 2026
@rueian
rueian marked this pull request as ready for review February 12, 2026 23:57
@rueian
rueian requested a review from a team as a code owner February 12, 2026 23:57

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a TypeError in the dashboard's list_jobs API that occurs when a job is deleted during the listing process. The fix correctly filters out None job information returned for deleted jobs, preventing the error. The change is simple, effective, and includes a new test case that properly validates the fix by simulating the race condition. This change also improves the robustness of other parts of the code that use get_all_jobs, such as in _recover_running_jobs, which would have otherwise failed with an AttributeError. The implementation is clean and I have no further suggestions.

@rueian
rueian force-pushed the fix-dashboard-asdict branch from 17a627d to 31878c9 Compare February 13, 2026 01:45
@rueian

rueian commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

cc @MengjinYan for review 🙏

@MengjinYan
MengjinYan merged commit e12b07e into ray-project:master Feb 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants