Skip to content

[ci][RLlib] [test utils] Improve error message on some test-failures because of IndexError in test_utils.py#54343

Merged
simonsays1980 merged 8 commits intoray-project:masterfrom
Daraan:improve-test-error-messages
Sep 18, 2025
Merged

[ci][RLlib] [test utils] Improve error message on some test-failures because of IndexError in test_utils.py#54343
simonsays1980 merged 8 commits intoray-project:masterfrom
Daraan:improve-test-error-messages

Conversation

@Daraan
Copy link
Contributor

@Daraan Daraan commented Jul 4, 2025

Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported correctly:

[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---

In the logs the actual error does not appear because of the IndexError for f"{[e.args[0].args[2] for e in results.errors]}". I am not sure why e.args[0].args[2] is used, a nested Exception perhaps? This PR adds a guard to fallback to a simpler repr(e) in case the IndexError would accur again. This allows to investigate why this IndexError occures and raises the RuntimeError like expected.

Related issue number

NA

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • This PR is not tested, but improves other tests :)

Daraan added 3 commits July 4, 2025 16:44
Signed-off-by: Daraan <github.blurry@9ox.net>
Signed-off-by: Daraan <github.blurry@9ox.net>
Signed-off-by: Daraan <github.blurry@9ox.net>
Copilot AI review requested due to automatic review settings July 4, 2025 15:02
@Daraan Daraan requested a review from a team as a code owner July 4, 2025 15:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error reporting in run_rllib_example_script_experiment by guarding against an IndexError when extracting nested exception messages and falling back to repr(e).

  • Adds a safe extraction of e.args[0].args[2] with a fallback to repr(e) if the tuple is too short.
  • Fixes a spelling typo in a comment (criteriscriteria).
  • Updates the raised RuntimeError to include the new errors list.
Comments suppressed due to low confidence (1)

rllib/utils/test_utils.py:1352

  • Add a unit test for this fallback branch to ensure that when nested exception args are too short, the code uses the fallback behavior as intended.
        # Might cause a Index error if Tuple is not long enough in that case use str(e)

@Daraan Daraan changed the title [Tests] Improve error message on some test-failures [Tests] Improve error message on some test-failures because of IndexError in test_utils.py Jul 4, 2025
Daraan and others added 3 commits July 4, 2025 17:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Daraan <github.blurry@9ox.net>
Signed-off-by: Daraan <github.blurry@9ox.net>
@cszhu cszhu added community-contribution Contributed by the community rllib RLlib related issues ci-test labels Jul 9, 2025
@github-actions
Copy link

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 Jul 24, 2025
@Daraan
Copy link
Contributor Author

Daraan commented Jul 24, 2025

(ง •_•)ง stale

@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 Jul 24, 2025
Copy link
Contributor

@kamil-kaczmarek kamil-kaczmarek left a comment

Choose a reason for hiding this comment

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

LGTM!

@kamil-kaczmarek kamil-kaczmarek changed the title [Tests] Improve error message on some test-failures because of IndexError in test_utils.py [RLlib] [test utils] Improve error message on some test-failures because of IndexError in test_utils.py Sep 18, 2025
@Daraan Daraan changed the title [RLlib] [test utils] Improve error message on some test-failures because of IndexError in test_utils.py [ci][RLlib] [test utils] Improve error message on some test-failures because of IndexError in test_utils.py Sep 18, 2025
@simonsays1980 simonsays1980 added the go add ONLY when ready to merge, run all tests label Sep 18, 2025
@simonsays1980 simonsays1980 enabled auto-merge (squash) September 18, 2025 17:13
@simonsays1980 simonsays1980 merged commit 7f2065e into ray-project:master Sep 18, 2025
6 of 7 checks passed
@Daraan Daraan deleted the improve-test-error-messages branch September 19, 2025 20:04
zma2 pushed a commit to zma2/ray that referenced this pull request Sep 23, 2025
…because of `IndexError` in `test_utils.py` (ray-project#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Signed-off-by: Zhiqiang Ma <zhiqiang.ma@intel.com>
ZacAttack pushed a commit to ZacAttack/ray that referenced this pull request Sep 24, 2025
…because of `IndexError` in `test_utils.py` (ray-project#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Signed-off-by: zac <zac@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Sep 24, 2025
…because of `IndexError` in `test_utils.py` (#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
marcostephan pushed a commit to marcostephan/ray that referenced this pull request Sep 24, 2025
…because of `IndexError` in `test_utils.py` (ray-project#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Signed-off-by: Marco Stephan <marco@magic.dev>
elliot-barn pushed a commit that referenced this pull request Sep 27, 2025
…because of `IndexError` in `test_utils.py` (#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
dstrodtman pushed a commit that referenced this pull request Oct 6, 2025
…because of `IndexError` in `test_utils.py` (#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Signed-off-by: Douglas Strodtman <douglas@anyscale.com>
justinyeh1995 pushed a commit to justinyeh1995/ray that referenced this pull request Oct 20, 2025
…because of `IndexError` in `test_utils.py` (ray-project#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
…because of `IndexError` in `test_utils.py` (ray-project#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
…because of `IndexError` in `test_utils.py` (ray-project#54343)

## Why are these changes needed?

In the CI I saw a fleaky test failing, but its error is not reported
correctly:

```python
[2025-07-04T00:01:57Z] Traceback (most recent call last):
[2025-07-04T00:01:57Z]   File "/root/.cache/bazel/_bazel_root/1df605deb6d24fc8068f6e25793ec703/execroot/com_github_ray_project_ray/bazel-out/k8-opt/bin/rllib/examples/connectors/multi_agent_observation_preprocessor.runfiles/com_github_ray_project_ray/rllib/examples/connectors/multi_agent_observation_preprocessor.py", line 137, in <module>
[2025-07-04T00:01:57Z]     run_rllib_example_script_experiment(base_config, args)
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in run_rllib_example_script_experiment
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"
[2025-07-04T00:01:57Z]   File "/rayci/python/ray/rllib/utils/test_utils.py", line 1354, in <listcomp>
[2025-07-04T00:01:57Z]     f"{[e.args[0].args[2] for e in results.errors]}"  # <---
[2025-07-04T00:01:57Z] IndexError: tuple index out of range  # <---
```

In the logs the actual error does not appear because of the `IndexError`
for ` f"{[e.args[0].args[2] for e in results.errors]}"`. I am not sure
why `e.args[0].args[2]` is used, a nested Exception perhaps? This PR
adds a guard to fallback to a simpler `repr(e)` in case the `IndexError`
would accur again. This allows to investigate why this `IndexError`
occures and raises the `RuntimeError` like expected.

## Related issue number

NA

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [x] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] This PR is not tested, but improves other tests :)

---------

Signed-off-by: Daraan <github.blurry@9ox.net>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Kamil Kaczmarek <kaczmarek.poczta@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-test community-contribution Contributed by the community go add ONLY when ready to merge, run all tests rllib RLlib related issues 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.

5 participants