Skip to content

Conversation

@kriyanshii
Copy link
Contributor

Description

ray: handle dual task errors with read-only args

  • avoid writing to user-defined args when building RayTaskError hybrids
  • fall back to RayTaskError-only with warning if subclassing fails
  • add regression test covering read-only args user exceptions

Related issues

Fixes #59437

ray: handle dual task errors with read-only args

- avoid writing to user-defined args when building RayTaskError hybrids
- fall back to RayTaskError-only with warning if subclassing fails
- add regression test covering read-only args user exceptions
@kriyanshii kriyanshii requested a review from a team as a code owner December 17, 2025 14:25
Copy link
Contributor

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

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 refactors how RayTaskError handles the args attribute of wrapped user exceptions. Previously, RayTaskError directly assigned to self.args, which could cause issues if the user's custom exception defined args as a read-only property. The changes introduce a private attribute _ray_task_error_args and implement args as a property with a setter, allowing RayTaskError to manage its own arguments without conflicting with potentially read-only user-defined args. Additionally, a new exception handler was added to as_instanceof_cause to log warnings when subclassing fails due to user exceptions overriding attributes like args. A new test case was added to verify that RayTaskError correctly wraps and propagates exceptions that have read-only args properties.

@ray-gardener ray-gardener bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Dec 17, 2025
@codope codope self-assigned this Dec 18, 2025
@codope codope added the go add ONLY when ready to merge, run all tests label Dec 18, 2025
Copy link
Contributor

@codope codope left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Just a small suggestion for more thorough testing.

[core][test] Added both assertions to test_task_error_with_read_only_args_property

assert isinstance(exc_info.value, ReadOnlyArgsError) to confirm dual inheritance
assert exc_info.value.args == (exc_info.value.cause,) to confirm the args shim works
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jan 2, 2026
@github-actions github-actions bot added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Jan 3, 2026
Copy link
Contributor

@codope codope left a comment

Choose a reason for hiding this comment

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

LGTM!
@edoakes @dayshah to merge

@edoakes edoakes merged commit 48b6ba7 into ray-project:master Jan 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core] Exception types that don't allow args to be set cannot be deserialized

3 participants