-
Notifications
You must be signed in to change notification settings - Fork 25
Correct params for list_groups and list_users
#512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Greptile SummaryThis PR attempts to fix issue #511 by changing the API parameter names from Critical Issue: This change is incorrect and will break all API calls. The WorkOS API expects parameters without the
Root Cause Analysis: The error in issue #511 (
Correct Fix: The type definitions in Confidence Score: 0/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant SDK as DirectorySync
participant Types as DirectoryUserListFilters
participant API as WorkOS API
User->>SDK: list_users(directory_id="dir_123")
Note over SDK: Function signature accepts directory_id
SDK->>Types: Create list_params dict
Note over SDK,Types: ISSUE: PR changes this to use directory_id
SDK->>Types: list_params["directory_id"] = "dir_123" ❌
Note over Types: Type expects "directory" key (no _id)
SDK->>API: GET /directory_users?directory_id=dir_123
Note over API: API expects "directory" not "directory_id"
API-->>SDK: Error: Unknown parameter
SDK-->>User: API Error
Note over User,API: Correct behavior (before this PR):
User->>SDK: list_users(directory_id="dir_123")
SDK->>Types: list_params["directory"] = "dir_123" ✓
SDK->>API: GET /directory_users?directory=dir_123
API-->>SDK: 200 OK with user list
SDK-->>User: DirectoryUsersListResource
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 4 comments
| list_params["group_id"] = group_id | ||
| if directory_id is not None: | ||
| list_params["directory"] = directory_id | ||
| list_params["directory_id"] = directory_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The WorkOS API expects group not group_id. The type definition in src/workos/types/directory_sync/list_filters.py:15 defines DirectoryUserListFilters with group: Optional[str], and tests at tests/test_directory_sync.py:166 verify this. This change will break API calls.
| list_params["group_id"] = group_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id | |
| list_params["directory_id"] = directory_id | |
| if group_id is not None: | |
| list_params["group"] = group_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/workos/directory_sync.py
Line: 187:189
Comment:
**logic:** The WorkOS API expects `group` not `group_id`. The type definition in `src/workos/types/directory_sync/list_filters.py:15` defines `DirectoryUserListFilters` with `group: Optional[str]`, and tests at `tests/test_directory_sync.py:166` verify this. This change will break API calls.
```suggestion
if group_id is not None:
list_params["group"] = group_id
if directory_id is not None:
list_params["directory"] = directory_id
```
How can I resolve this? If you propose a fix, please make it concise.| list_params["user_id"] = user_id | ||
| if directory_id is not None: | ||
| list_params["directory"] = directory_id | ||
| list_params["directory_id"] = directory_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The WorkOS API expects user and directory not user_id and directory_id. The type definition in src/workos/types/directory_sync/list_filters.py:20-21 defines DirectoryGroupListFilters with user: Optional[str] and directory: Optional[str], and tests at tests/test_directory_sync.py:184,202 verify this. This change will break API calls.
| list_params["user_id"] = user_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id | |
| list_params["directory_id"] = directory_id | |
| if user_id is not None: | |
| list_params["user"] = user_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/workos/directory_sync.py
Line: 221:223
Comment:
**logic:** The WorkOS API expects `user` and `directory` not `user_id` and `directory_id`. The type definition in `src/workos/types/directory_sync/list_filters.py:20-21` defines `DirectoryGroupListFilters` with `user: Optional[str]` and `directory: Optional[str]`, and tests at `tests/test_directory_sync.py:184,202` verify this. This change will break API calls.
```suggestion
if user_id is not None:
list_params["user"] = user_id
if directory_id is not None:
list_params["directory"] = directory_id
```
How can I resolve this? If you propose a fix, please make it concise.| list_params["group_id"] = group_id | ||
| if directory_id is not None: | ||
| list_params["directory"] = directory_id | ||
| list_params["directory_id"] = directory_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Same issue in async version: API expects group and directory not group_id and directory_id. This will break async API calls.
| list_params["group_id"] = group_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id | |
| list_params["directory_id"] = directory_id | |
| if group_id is not None: | |
| list_params["group"] = group_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/workos/directory_sync.py
Line: 325:327
Comment:
**logic:** Same issue in async version: API expects `group` and `directory` not `group_id` and `directory_id`. This will break async API calls.
```suggestion
if group_id is not None:
list_params["group"] = group_id
if directory_id is not None:
list_params["directory"] = directory_id
```
How can I resolve this? If you propose a fix, please make it concise.| list_params["user_id"] = user_id | ||
| if directory_id is not None: | ||
| list_params["directory"] = directory_id | ||
| list_params["directory_id"] = directory_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Same issue in async version: API expects user and directory not user_id and directory_id. This will break async API calls.
| list_params["user_id"] = user_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id | |
| list_params["directory_id"] = directory_id | |
| if user_id is not None: | |
| list_params["user"] = user_id | |
| if directory_id is not None: | |
| list_params["directory"] = directory_id |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/workos/directory_sync.py
Line: 358:360
Comment:
**logic:** Same issue in async version: API expects `user` and `directory` not `user_id` and `directory_id`. This will break async API calls.
```suggestion
if user_id is not None:
list_params["user"] = user_id
if directory_id is not None:
list_params["directory"] = directory_id
```
How can I resolve this? If you propose a fix, please make it concise.15e7129 to
b52216b
Compare
b52216b to
face195
Compare
|
Note that Greptile is confused here, the API ref shows the |
Description
The provided parameters were not matching the actual parameters the API was expecting.
Closes #511.
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.