Skip to content

fix: listEnvironmentRoles should not use PaginatedResource#341

Merged
gjtorikian merged 1 commit intomainfrom
fix/list-environment-roles
Mar 9, 2026
Merged

fix: listEnvironmentRoles should not use PaginatedResource#341
gjtorikian merged 1 commit intomainfrom
fix/list-environment-roles

Conversation

@csrbarber
Copy link
Contributor

@csrbarber csrbarber commented Mar 9, 2026

Summary

  • The authorization/roles endpoint is not paginated, but listEnvironmentRoles was using PaginatedResource::constructFromResponse which calls parsePaginationArgs and expects list_metadata in the response
  • This caused an Undefined array key "list_metadata" error when customers called listEnvironmentRoles
  • Changed to iterate $response["data"] directly and return Resource\Role[], matching listOrganizationRoles

Test plan

  • All 19 RBAC tests pass
  • Manually verify listEnvironmentRoles returns roles without error

🤖 Generated with Claude Code

The authorization/roles endpoint is not paginated, so using
PaginatedResource causes an "Undefined array key list_metadata" error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@csrbarber csrbarber requested review from a team as code owners March 9, 2026 13:50
@csrbarber csrbarber requested a review from nicknisi March 9, 2026 13:50
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 9, 2026

Greptile Summary

This PR fixes a runtime bug in listEnvironmentRoles where using PaginatedResource::constructFromResponse caused an Undefined array key "list_metadata" error because the authorization/roles endpoint does not return a paginated response. The fix aligns the method with listOrganizationRoles, which already handled this correctly by iterating $response["data"] directly and returning Resource\Role[].

Key changes:

  • Removed pagination parameters ($limit, $before, $after, $order) from listEnvironmentRoles since the endpoint does not support them
  • Replaced PaginatedResource::constructFromResponse(...) with a direct loop over $response["data"], consistent with listOrganizationRoles
  • Updated the corresponding test to remove pagination params, drop list_metadata from the fixture (reflecting the actual API response), and assert directly against the Role[] return value

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted bug fix with no regressions or side effects.
  • The change is a straightforward fix: the implementation now exactly mirrors the already-correct listOrganizationRoles method, the test fixture correctly reflects what the real API returns, and there are no broader architectural or security implications.
  • No files require special attention.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant RBAC
    participant Client
    participant API as WorkOS API

    Caller->>RBAC: listEnvironmentRoles()
    RBAC->>Client: GET authorization/roles
    Client->>API: HTTP GET /authorization/roles
    API-->>Client: { "object": "list", "data": [...] }
    Client-->>RBAC: $response (array)
    loop foreach $response["data"]
        RBAC->>RBAC: Role::constructFromResponse($responseData)
    end
    RBAC-->>Caller: Role[]
Loading

Last reviewed commit: e6046d8

@gjtorikian gjtorikian merged commit 52f0602 into main Mar 9, 2026
9 checks passed
@gjtorikian gjtorikian deleted the fix/list-environment-roles branch March 9, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants