Skip to content

Conversation

@sampan-s-nayak
Copy link
Contributor

Description

in the original taskEvent proto, worker_id is marked as optional

optional bytes worker_id = 8;

but in ray event it is not

in the converter we always set the worker_id field even if its an empty string https://github.com/ray-project/ray/blob/master/src/ray/gcs/gcs_ray_event_converter.cc#L145. if an optional field is set, even if it is empty(default proto value) it is considered as having a value, and during mergeFrom() calls the value is considered and overwrites the destination objects existing value.

source:https://protobuf.dev/programming-guides/field_presence/
Explicitly set fields – including default values – are merged-from

this pr fixes this gap in the conversion logic

sampan added 2 commits October 24, 2025 08:38
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
@sampan-s-nayak sampan-s-nayak requested a review from a team as a code owner October 24, 2025 08:40
@sampan-s-nayak sampan-s-nayak added the go add ONLY when ready to merge, run all tests label Oct 24, 2025
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 correctly addresses an issue with how optional fields from TaskLifecycleEvent are handled during conversion. By conditionally setting fields like node_id, worker_id, worker_pid, and ray_error_info only when they have non-default values, you've prevented unintended overwrites during protobuf merges. The logic change is sound and directly fixes the described problem.

The addition of comprehensive tests is excellent. The parameterized test for node_id, worker_id, and worker_pid covers a wide range of scenarios effectively. I've left one suggestion in the test file to refactor the ray_error_info test to reduce code duplication and align it with the parameterized testing pattern used elsewhere in the file.

Overall, this is a solid improvement that enhances the robustness of the event conversion logic.

Signed-off-by: sampan <sampan@anyscale.com>
@ray-gardener ray-gardener bot added core Issues that should be addressed in Ray Core observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling labels Oct 24, 2025
Copy link
Contributor

@can-anyscale can-anyscale left a comment

Choose a reason for hiding this comment

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

task_event.set_attempt_number(event.attempt_number());
task_event.set_job_id(event.job_id());

*task_event.mutable_profile_events() = std::move(*event.mutable_profile_events());
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to check for provile event emptiness before moving, similar to ray error info?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes; either we do the same thing here or line 155 doesn't need the if condition; i think for actual protobuf message (not scalar), we don't need to have the if condition (the mergeFrom work fine when merging empty message)

*task_state_update->mutable_error_info() = std::move(*event.mutable_ray_error_info());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ill do the same as what we are doing for error_info for consistency

Signed-off-by: sampan <sampan@anyscale.com>
Copy link
Contributor

@can-anyscale can-anyscale left a comment

Choose a reason for hiding this comment

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

@can-anyscale
Copy link
Contributor

build are failing though

@sampan-s-nayak
Copy link
Contributor Author

failures seem unrelated to changes in this pr, merging with main to see if that helps.

@can-anyscale
Copy link
Contributor

yeah master branch is probably broken

@can-anyscale
Copy link
Contributor

let's go

@can-anyscale can-anyscale merged commit 4b0a268 into master Oct 27, 2025
6 checks passed
@can-anyscale can-anyscale deleted the even_converter_fix branch October 27, 2025 22:20
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
## Description
in the original taskEvent proto, worker_id is marked as optional
https://github.com/ray-project/ray/blob/830a456b9b558028853423c9042f7e2763ec5283/src/ray/protobuf/gcs.proto#L201

but in ray event it is not
https://github.com/ray-project/ray/blob/f635de7c86d0d0f813a305a9fd5e864a64257894/src/ray/protobuf/public/events_task_lifecycle_event.proto#L42

in the converter we always set the worker_id field even if its an empty
string
https://github.com/ray-project/ray/blob/master/src/ray/gcs/gcs_ray_event_converter.cc#L145.
if an optional field is set, even if it is empty(default proto value) it
is considered as having a value, and during mergeFrom() calls the value
is considered and overwrites the destination objects existing value.

source:https://protobuf.dev/programming-guides/field_presence/
Explicitly set fields – including default values – are merged-from


this pr fixes this gap in the conversion logic

---------

Signed-off-by: sampan <sampan@anyscale.com>
Co-authored-by: sampan <sampan@anyscale.com>
Co-authored-by: Jiajun Yao <jeromeyjj@gmail.com>
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Nov 19, 2025
## Description
in the original taskEvent proto, worker_id is marked as optional
https://github.com/ray-project/ray/blob/830a456b9b558028853423c9042f7e2763ec5283/src/ray/protobuf/gcs.proto#L201

but in ray event it is not
https://github.com/ray-project/ray/blob/f635de7c86d0d0f813a305a9fd5e864a64257894/src/ray/protobuf/public/events_task_lifecycle_event.proto#L42

in the converter we always set the worker_id field even if its an empty
string
https://github.com/ray-project/ray/blob/master/src/ray/gcs/gcs_ray_event_converter.cc#L145.
if an optional field is set, even if it is empty(default proto value) it
is considered as having a value, and during mergeFrom() calls the value
is considered and overwrites the destination objects existing value.

source:https://protobuf.dev/programming-guides/field_presence/
Explicitly set fields – including default values – are merged-from

this pr fixes this gap in the conversion logic

---------

Signed-off-by: sampan <sampan@anyscale.com>
Co-authored-by: sampan <sampan@anyscale.com>
Co-authored-by: Jiajun Yao <jeromeyjj@gmail.com>
Signed-off-by: Aydin Abiar <aydin@anyscale.com>
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 observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants