Skip to content

feat: add resource_type_slug to permissions, environment and organization roles#576

Open
csrbarber wants to merge 1 commit intomainfrom
resource-type-slug-support
Open

feat: add resource_type_slug to permissions, environment and organization roles#576
csrbarber wants to merge 1 commit intomainfrom
resource-type-slug-support

Conversation

@csrbarber
Copy link
Contributor

Description

  • Add resource_type_slug to permission, environment role, and organization role response deserialization
  • Add optional resource_type_slug to permission and environment role creation

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[X] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@csrbarber csrbarber requested a review from a team as a code owner February 27, 2026 20:19
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

This PR adds resource_type_slug support to the authorization module. The field is added as a required field in Permission, EnvironmentRole, and OrganizationRole response models, and as an optional parameter in create_permission and create_environment_role methods (but not create_organization_role).

Key Changes:

  • Added required resource_type_slug: str field to Permission, EnvironmentRole, and OrganizationRole type definitions
  • Added optional resource_type_slug parameter to create_permission and create_environment_role methods (sync and async)
  • Updated all test fixtures to include the new field with default value "organization"
  • Added test coverage for creating resources with explicit resource_type_slug values

Important Note:
The resource_type_slug field is defined as required (non-optional) in the Pydantic models. This means the API must always return this field in responses, otherwise deserialization will fail. Ensure this change is coordinated with corresponding API updates that guarantee this field is always present.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk, assuming API coordination
  • Clean implementation with comprehensive test coverage. Score is 4 (not 5) because resource_type_slug is defined as a required field, which could cause deserialization failures if the API doesn't always return it. This appears to be coordinated with API changes based on tests, but requires verification.
  • src/workos/types/authorization/permission.py, src/workos/types/authorization/environment_role.py, and src/workos/types/authorization/organization_role.py require verification that the API always returns resource_type_slug

Important Files Changed

Filename Overview
src/workos/authorization.py Added optional resource_type_slug parameter to create_permission and create_environment_role methods across sync and async implementations
src/workos/types/authorization/permission.py Added required resource_type_slug: str field to Permission model
src/workos/types/authorization/environment_role.py Added required resource_type_slug: str field to EnvironmentRole model
src/workos/types/authorization/organization_role.py Added required resource_type_slug: str field to OrganizationRole and OrganizationRoleEvent models

Last reviewed commit: e37c377

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

slug: str
name: str
description: Optional[str] = None
resource_type_slug: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify API always returns this field - without Optional or default, Pydantic fails if missing.

name: str
slug: str
description: Optional[str] = None
resource_type_slug: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify API always returns this field - without Optional or default, Pydantic fails if missing.

name: str
slug: str
description: Optional[str] = None
resource_type_slug: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify API always returns this field - without Optional or default, Pydantic fails if missing.

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.

1 participant