fix(directory): expose directory_group_id filter in list_directory_users#149
fix(directory): expose directory_group_id filter in list_directory_users#149ravibits wants to merge 5 commits into
Conversation
The proto field existed (field 6 in ListDirectoryUsersRequest) but was never wired through the Python SDK wrapper. Adds the missing param and test coverage for filtering by group and listing groups. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR adds an optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/test_directory.py (1)
144-162: Strengthen the group-filter test so it actually validates filtering/wiring.At Lines 157-161, asserting
len(response[0].users) == 0with a nonexistent group can pass even ifdirectory_group_idis ignored (because the directory may already have no users). Consider asserting request wiring via a unit-level mock or using fixture data where unfiltered results are non-empty and filtered results differ.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_directory.py` around lines 144 - 162, The test test_list_directory_users_filter_by_group currently asserts zero users for a nonexistent directory_group_id which can pass even if directory_group_id is ignored; change it to explicitly validate the filter wiring by either (a) creating fixture data: create at least one user in the directory and a separate user assigned to a real group, then call list_directory_users twice (once without directory_group_id and once with a valid directory_group_id) and assert the unfiltered response contains users while the filtered response only contains the group member(s), or (b) use a unit-level mock for scalekit_client.directory.list_directory_users to assert it was called with the directory_group_id parameter; locate the test by function name test_list_directory_users_filter_by_group and update calls to list_directory_users and the setup using CreateDirectory/CreateOrganization to ensure the scenario proves the filter is applied.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scalekit/directory.py`:
- Around line 75-76: The parameter order change in list_directory_users broke
positional-argument compatibility: move updated_after before directory_group_id
so existing positional callers keep passing their sixth argument to
updated_after; update the function signature of list_directory_users to restore
the original parameter ordering (place updated_after ahead of
directory_group_id) and ensure any internal calls or references to these
parameter names remain working with the restored order.
---
Nitpick comments:
In `@tests/test_directory.py`:
- Around line 144-162: The test test_list_directory_users_filter_by_group
currently asserts zero users for a nonexistent directory_group_id which can pass
even if directory_group_id is ignored; change it to explicitly validate the
filter wiring by either (a) creating fixture data: create at least one user in
the directory and a separate user assigned to a real group, then call
list_directory_users twice (once without directory_group_id and once with a
valid directory_group_id) and assert the unfiltered response contains users
while the filtered response only contains the group member(s), or (b) use a
unit-level mock for scalekit_client.directory.list_directory_users to assert it
was called with the directory_group_id parameter; locate the test by function
name test_list_directory_users_filter_by_group and update calls to
list_directory_users and the setup using CreateDirectory/CreateOrganization to
ensure the scenario proves the filter is applied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f4d4db48-083b-46e1-9550-5580d7d08797
📒 Files selected for processing (2)
scalekit/directory.pytests/test_directory.py
…mpty users attr on ListDirUsersResponse is only set when the loop runs — accessing it on an empty response raises AttributeError. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…up filter test - Initialize users=[] and groups=[] before mapping loops in list_directory_users and list_directory_groups — slots were unset causing AttributeError on non-empty responses - Replace weak group filter test (nonexistent ID) with real SCIM-seeded test: creates a user+group via SCIM, asserts filtered result contains exactly that user Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ve positional arg order Inserting before updated_after would silently break callers passing updated_after positionally. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Summary
list_directory_userswas missing thedirectory_group_idparameter despite it being defined as field 6 in theListDirectoryUsersRequestprotodirectory_group_id: Optional[str] = Noneto the method signature and wired it through to the gRPC requesttest_list_directory_users,test_list_directory_users_filter_by_group,test_list_directory_groupsTest plan
test_list_directory_users— basic call returns OK with no filtertest_list_directory_users_filter_by_group— passing a group ID is accepted, returns empty users list for nonexistent grouptest_list_directory_groups— basic group listing returns OK🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests