Skip to content

Fix the path of provisioning.user_in_user_groups - #453

Open
TalLevAmi wants to merge 1 commit into
masterfrom
fix/user-in-user-groups-path
Open

TalLevAmi wants to merge 1 commit into
masterfrom
fix/user-in-user-groups-path

Conversation

@TalLevAmi

Copy link
Copy Markdown

Brief Summary of Changes

cloudinary.provisioning.user_in_user_groups(user_id) sent GET /user_groups/{user_id}. That endpoint is "Get User Group" (getUserGroup): it gets one user group by its group ID. The method sent a user ID in that place, so it returned a 404 or the wrong object, and never the groups of the user.

This PR changes the path to GET /users/{user_id}/groups ("Get user groups", getGroupsForUser). This is what the method docstring says ("Get all user groups a user belongs to").

  • cloudinary/provisioning/account.py: uri = [USERS_SUB_PATH, user_id, "groups"].
  • test/test_provisioning_api.py: a new mocked test checks the HTTP method and the path. It gives the credentials as options, so it runs with no account.

The wrong path has been there since the method was added in 4a947b3 (2020). No test called the method before.

What does this PR address?

  • GitHub issue (Add reference - #XX)
  • Refactoring
  • New feature
  • Bug fix
  • Adds more tests

Are tests included?

  • Yes
  • No

Reviewer, please note:

  • Evidence: the provisioning OpenAPI spec (https://cloudinary.github.io/api-schemas/provisioning/schema.yml) has /v1_1/provisioning/accounts/{account_id}/users/{user_id}/groups (GET, getGroupsForUser, response {groups: [...]}). /user_groups/{group_id} is a different operation (getUserGroup).
  • Reference to other Cloudinary SDKs: the generated provisioning SDKs use the same path: cloudinary/account-provisioning-js src/funcs/users-get-groups.ts and cloudinary/account-provisioning-go cldprovisioning/users.go. The Node, Ruby, Java and PHP SDKs do not have this method.
  • Return value: the call now returns {"groups": [...]}, as the docstring and the spec say. Code that used the old result depended on a wrong response, so this is unlikely to break users.
  • I could not test this against the live API, because I do not have account-level credentials.
  • I did not add a CHANGELOG entry, because the release process adds it.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I ran the full test suite before pushing the changes and all the tests pass.

Tests: pytest test/test_provisioning_api.py gives 17 passed and 20 skipped (the skipped tests need a live account). The new test fails without the fix (the URI was .../user_groups/user_id) and passes with it.

🤖 Generated with Claude Code

`user_in_user_groups(user_id)` sent `GET /user_groups/{user_id}`. That
endpoint gets one user group by its group ID, so the call sent a user ID
as a group ID. It returned a 404 or the wrong object, not the groups of
the user.

Call `GET /users/{user_id}/groups`, as the Provisioning API spec
(`getGroupsForUser`) and the method docstring say. Add a mocked test
that checks the method and the path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TalLevAmi
TalLevAmi marked this pull request as ready for review September 27, 2026 07:00
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.

1 participant