fix: send raw array body for remove_role_users/remove_role_admins [no-ado]#135
Merged
Conversation
…-ado]
The API parses DELETE /api/2/roles/{role_id}/users and /admins with a
strict array parser and rejects the object form with 400 'Expected
array in request' (issue #134). Both methods now send a raw JSON array
and accept a plain List[int], matching add_role_users. The deprecated
RemoveRoleUsersRequest form is still accepted and unwrapped.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the remove_role_users / remove_role_admins Roles API methods to send the request body as a raw JSON array of user IDs (matching the OneLogin API’s expectations), while keeping backward compatibility with the legacy RemoveRoleUsersRequest model by unwrapping it before sending.
Changes:
- Update
RolesApi.remove_role_usersandRolesApi.remove_role_adminsto acceptList[int]-style input (and unwrapRemoveRoleUsersRequest), ensuring the wire body is a raw JSON array. - Add regression tests that assert the actual HTTP-layer body sent for both list and legacy-model call styles.
- Update docs + changelog and bump the project version to
4.0.1.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
onelogin/api/roles_api.py |
Accept list input (or legacy model) and ensure DELETE bodies serialize as raw JSON arrays. |
onelogin/models/remove_role_users_request.py |
Document RemoveRoleUsersRequest as deprecated and clarify expected raw-array behavior. |
test/test_roles_api.py |
Add regression tests asserting the exact serialized request body for both endpoints. |
docs/RolesApi.md |
Update parameter docs/examples to use List[int] and note legacy-model deprecation. |
docs/RemoveRoleUsersRequest.md |
Mark the model as deprecated and document unwrapping behavior. |
CHANGELOG.md |
Add 4.0.1 entry describing the fix and compatibility behavior. |
pyproject.toml |
Bump package metadata version to 4.0.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #134.
remove_role_usersandremove_role_adminshave been broken since the SDK was generated. They serialize the request body as{"user_id": [123, 456]}, but the API parsesDELETE /api/2/roles/{role_id}/users(and/admins) with a strict array parser and rejects anything that isn't a raw JSON array:The sibling
add_role_usershas always sent the correct raw-array body — the OpenAPI spec transcribed the wrong shape for the two DELETE operations only (likely from the docs page's parameter table, whose curl example correctly shows-d '[123, 456, 789]').Fix
List[int](matchingadd_role_users) and always serialize the body as a raw JSON array.RemoveRoleUsersRequeststill works — it is unwrapped to the raw array before sending — so the exact code from Remove role users failing #134 now succeeds without changes. The class is documented as deprecated.pool_manager.requestmock pattern) for the plain-list and legacy-model call styles on both endpoints.Testing
pytest test/: 73 passed (including 3 new regression tests).ruff check .: clean.Note: the Node SDK had the same bug but was already fixed (March 2025, sends
userIdsdirectly). The staleonelogin-openapispec repo also carries the wrong shape, but it is unmaintained and no longer feeds this SDK, so it is intentionally left alone.