Skip to content

fix(jumanji): prevent IndexError in routing render when no valid nodes - #416

Merged
Trinkle23897 merged 1 commit into
sail-sg:mainfrom
hobostay:fix/jumanji-routing-index-error
May 22, 2026
Merged

fix(jumanji): prevent IndexError in routing render when no valid nodes#416
Trinkle23897 merged 1 commit into
sail-sg:mainfrom
hobostay:fix/jumanji-routing-index-error

Conversation

@hobostay

Copy link
Copy Markdown
Contributor

Summary

Fix an IndexError in the Jumanji routing renderer's build_edges() method that crashes when an agent has no valid connected nodes.

Root Cause

In envpool/jumanji/_official_render/routing.py line 656:

len_conn = np.where(conn_group != -1)[0][-1]

When conn_group contains only -1 values (no valid connected nodes for an agent), np.where(conn_group != -1)[0] returns an empty array. Accessing [-1] on an empty array raises IndexError.

Fix

Add a guard to check if there are valid indices before proceeding:

valid_indices = np.where(conn_group != -1)[0]
if len(valid_indices) == 0:
    continue
len_conn = valid_indices[-1]

Test plan

  • Verify rendering works when all agents have valid connected nodes
  • Verify no crash when an agent has no valid connected nodes

@hobostay
hobostay force-pushed the fix/jumanji-routing-index-error branch from 7e993b8 to c0ecb6a Compare May 22, 2026 15:13
@Trinkle23897
Trinkle23897 merged commit db8be74 into sail-sg:main May 22, 2026
10 of 12 checks passed
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.

2 participants