chore: update proto to v0.1.121.2#158
Conversation
- Regenerated gRPC stubs from proto v0.1.121.2 - Implemented: UpdateOrganizationSessionPolicy, GetOrganizationSessionPolicy, GetApplicationSessionPolicy, SearchOrganization, GetOrganizationUserManagementSetting, SearchUsers, SearchOrganizationUsers, AssignUserRoles, RemoveUserRole - Breaking changes: none (removed SessionSettings RPCs were never wrapped) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WalkthroughUpdated proto reference to v0.1.121.2, extending the Python SDK with organization session policy management, organization/user search, and role management APIs. Regenerated protobuf modules include new agentkit logging/analytics support and schema updates across authentication, organizations, connected accounts, domains, environments, tools, and providers. ChangesSDK and Proto Regeneration
🎯 4 (Complex) | ⏱️ ~60 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 (2)
scalekit/organization.py (1)
235-244: ⚡ Quick winAdd explicit enum types for new public API parameters.
policy_source,absolute_session_timeout_unit, andidle_session_timeout_unitshould be explicitly typed to improve SDK correctness and developer ergonomics.✍️ Suggested signature update
def update_organization_session_policy( self, organization_id: str, - policy_source, + policy_source: SessionPolicyType, absolute_session_timeout: Optional[int] = None, - absolute_session_timeout_unit=None, + absolute_session_timeout_unit: Optional[TimeUnit] = None, idle_session_timeout_enabled: Optional[bool] = None, idle_session_timeout: Optional[int] = None, - idle_session_timeout_unit=None, + idle_session_timeout_unit: Optional[TimeUnit] = None, ) -> UpdateOrganizationSessionPolicyResponse:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@scalekit/organization.py` around lines 235 - 244, The update_organization_session_policy method's public parameters lack explicit enum types; change the signature of update_organization_session_policy so that policy_source, absolute_session_timeout_unit, and idle_session_timeout_unit are typed with the appropriate enum classes (e.g., PolicySourceEnum, TimeUnitEnum or whatever project-specific enums you have), import those enum types at top of the module, and update any callers/tests/type hints accordingly; keep Optional[...] where nullable, preserve default values, and ensure the return type UpdateOrganizationSessionPolicyResponse remains unchanged.tests/test_organization.py (1)
220-228: ⚡ Quick winStrengthen the search test assertion to validate behavior, not just transport success.
On Line 226, the query is hardcoded to
"test"while the created org name is random, and Lines 227-228 only assert status/object presence. This can pass even if search results are wrong. Assert that returned organizations contain the created org (or query with a deterministic substring fromorganization.display_name).Suggested test tightening
- response = self.scalekit_client.organization.search_organizations(query="test") + query = organization.display_name[:5] + response = self.scalekit_client.organization.search_organizations(query=query) self.assertEqual(response[1].code().name, "OK") self.assertTrue(response[0] is not None) + self.assertTrue( + any(org.id == self.org_id for org in response[0].organizations), + "Created organization was not returned by search" + )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_organization.py` around lines 220 - 228, The test_search_organizations test uses a hardcoded query and only checks transport success; update it to query using a deterministic substring from the created organization's display_name (from the CreateOrganization instance) and assert that the search results include the created organization (e.g., match org_response[0].organization.id or organization.display_name) by inspecting the payload returned by self.scalekit_client.organization.search_organizations, rather than just checking response[1].code() and non-null response[0]; ensure you still keep self.org_id assignment from org_response to compare against search results.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_users.py`:
- Around line 547-557: The try/except blocks around the client calls (notably
the call to self.scalekit_client.users.assign_user_roles and the other block at
569-583) currently catch Exception which masks assertion failures; change the
except to only catch the client/network errors you expect (e.g., grpc.RpcError,
TimeoutError, requests.exceptions.RequestException or your SDK's specific error
type) or, if you must catch broad exceptions, immediately re-raise
AssertionError (if isinstance(exp, AssertionError): raise) so test assertions
still fail; in short, narrow the except clauses to expected client errors or
re-raise assertion/fatal exceptions so real test failures are not converted into
skipped tests.
---
Nitpick comments:
In `@scalekit/organization.py`:
- Around line 235-244: The update_organization_session_policy method's public
parameters lack explicit enum types; change the signature of
update_organization_session_policy so that policy_source,
absolute_session_timeout_unit, and idle_session_timeout_unit are typed with the
appropriate enum classes (e.g., PolicySourceEnum, TimeUnitEnum or whatever
project-specific enums you have), import those enum types at top of the module,
and update any callers/tests/type hints accordingly; keep Optional[...] where
nullable, preserve default values, and ensure the return type
UpdateOrganizationSessionPolicyResponse remains unchanged.
In `@tests/test_organization.py`:
- Around line 220-228: The test_search_organizations test uses a hardcoded query
and only checks transport success; update it to query using a deterministic
substring from the created organization's display_name (from the
CreateOrganization instance) and assert that the search results include the
created organization (e.g., match org_response[0].organization.id or
organization.display_name) by inspecting the payload returned by
self.scalekit_client.organization.search_organizations, rather than just
checking response[1].code() and non-null response[0]; ensure you still keep
self.org_id assignment from org_response to compare against search results.
🪄 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: c4383fa0-8862-456b-a183-9388576f8b67
📒 Files selected for processing (37)
Makefilescalekit/organization.pyscalekit/users.pyscalekit/v1/agentkit_logs/__init__.pyscalekit/v1/agentkit_logs/agentkit_analytics_pb2.pyscalekit/v1/agentkit_logs/agentkit_analytics_pb2.pyiscalekit/v1/agentkit_logs/agentkit_analytics_pb2_grpc.pyscalekit/v1/agentkit_logs/agentkit_logs_pb2.pyscalekit/v1/agentkit_logs/agentkit_logs_pb2.pyiscalekit/v1/agentkit_logs/agentkit_logs_pb2_grpc.pyscalekit/v1/auth/auth_pb2.pyscalekit/v1/auth/auth_pb2.pyiscalekit/v1/clients/clients_pb2.pyscalekit/v1/clients/clients_pb2.pyiscalekit/v1/commons/commons_pb2.pyscalekit/v1/commons/commons_pb2.pyiscalekit/v1/connected_accounts/connected_accounts_pb2.pyscalekit/v1/connected_accounts/connected_accounts_pb2.pyiscalekit/v1/connected_accounts/connected_accounts_pb2_grpc.pyscalekit/v1/connections/connections_pb2.pyscalekit/v1/connections/connections_pb2.pyiscalekit/v1/domains/domains_pb2.pyscalekit/v1/domains/domains_pb2.pyiscalekit/v1/domains/domains_pb2_grpc.pyscalekit/v1/environments/environments_pb2.pyscalekit/v1/environments/environments_pb2.pyiscalekit/v1/options/options_pb2.pyscalekit/v1/options/options_pb2.pyiscalekit/v1/organizations/organizations_pb2.pyscalekit/v1/organizations/organizations_pb2.pyiscalekit/v1/organizations/organizations_pb2_grpc.pyscalekit/v1/providers/providers_pb2.pyscalekit/v1/providers/providers_pb2.pyiscalekit/v1/tools/tools_pb2.pyscalekit/v1/tools/tools_pb2.pyitests/test_organization.pytests/test_users.py
| try: | ||
| response = self.scalekit_client.users.assign_user_roles( | ||
| organization_id=self.org_id, | ||
| user_id=self.user_id, | ||
| role_ids=["member"] | ||
| ) | ||
| self.assertEqual(response[1].code().name, "OK") | ||
| self.assertTrue(response[0] is not None) | ||
| except Exception as exp: | ||
| self.skipTest(f"Skipping assign user roles test due to error: {exp}") | ||
|
|
There was a problem hiding this comment.
Narrow exception handling so failed assertions don’t get skipped.
In Line 547 and Line 569 blocks, except Exception can mask real test failures (including assertion failures) by turning them into skipTest.
✅ Suggested fix
- try:
- response = self.scalekit_client.users.assign_user_roles(
- organization_id=self.org_id,
- user_id=self.user_id,
- role_ids=["member"]
- )
- self.assertEqual(response[1].code().name, "OK")
- self.assertTrue(response[0] is not None)
- except Exception as exp:
- self.skipTest(f"Skipping assign user roles test due to error: {exp}")
+ try:
+ response = self.scalekit_client.users.assign_user_roles(
+ organization_id=self.org_id,
+ user_id=self.user_id,
+ role_ids=["member"]
+ )
+ except (ScalekitNotFoundException, ScalekitBadRequestException) as exp:
+ self.skipTest(f"Skipping assign user roles test due to expected error: {exp}")
+ self.assertEqual(response[1].code().name, "OK")
+ self.assertTrue(response[0] is not None)- try:
- # First assign a role so we can remove it
- self.scalekit_client.users.assign_user_roles(
- organization_id=self.org_id,
- user_id=self.user_id,
- role_ids=["member"]
- )
- response = self.scalekit_client.users.remove_user_role(
- organization_id=self.org_id,
- user_id=self.user_id,
- role_id="member"
- )
- self.assertEqual(response[1].code().name, "OK")
- except Exception as exp:
- self.skipTest(f"Skipping remove user role test due to error: {exp}")
+ try:
+ self.scalekit_client.users.assign_user_roles(
+ organization_id=self.org_id,
+ user_id=self.user_id,
+ role_ids=["member"]
+ )
+ response = self.scalekit_client.users.remove_user_role(
+ organization_id=self.org_id,
+ user_id=self.user_id,
+ role_id="member"
+ )
+ except (ScalekitNotFoundException, ScalekitBadRequestException) as exp:
+ self.skipTest(f"Skipping remove user role test due to expected error: {exp}")
+ self.assertEqual(response[1].code().name, "OK")Also applies to: 569-583
🧰 Tools
🪛 Ruff (0.15.12)
[warning] 555-555: Do not catch blind exception: Exception
(BLE001)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/test_users.py` around lines 547 - 557, The try/except blocks around the
client calls (notably the call to self.scalekit_client.users.assign_user_roles
and the other block at 569-583) currently catch Exception which masks assertion
failures; change the except to only catch the client/network errors you expect
(e.g., grpc.RpcError, TimeoutError, requests.exceptions.RequestException or your
SDK's specific error type) or, if you must catch broad exceptions, immediately
re-raise AssertionError (if isinstance(exp, AssertionError): raise) so test
assertions still fail; in short, narrow the except clauses to expected client
errors or re-raise assertion/fatal exceptions so real test failures are not
converted into skipped tests.
Proto Update
Updates generated gRPC stubs and SDK wrappers to proto version
v0.1.121.2.Changes since last version (v0.1.116.0 → v0.1.121.2)
Pre-existing gaps also filled
Breaking changes
None — the removed SessionSettings RPCs (CreateOrganizationSessionSettings, GetOrganizationSessionSettings, UpdateOrganizationSessionSettings, DeleteOrganizationSessionSettings) were never wrapped in this SDK.
Checklist
Summary by CodeRabbit