feat: warn when NominalClient is created without a workspace RID#752
feat: warn when NominalClient is created without a workspace RID#752seanmreidy wants to merge 10 commits into
Conversation
Tenants with multiple workspaces and no default workspace set will fail when operations require a workspace. This warning surfaces that early. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| UserWarning, | ||
| stacklevel=2, | ||
| ) | ||
| trust_store_path = certifi.where() if trust_store_path is None else trust_store_path |
There was a problem hiding this comment.
Missing Test Coverage: This warning functionality needs comprehensive tests to ensure it works correctly. Consider adding tests using pytest.warns() to verify:
- Warning is emitted when
workspace_rid=None - No warning when
workspace_ridis provided - Warning message and category are correct
- Stacklevel correctly points to user code
The warning should also be tested for the create() and from_profile() code paths mentioned in the PR description.
There was a problem hiding this comment.
Seems a bit excessive for just a warning message
Review SummaryThis PR successfully adds a deprecation warning when NominalClient is created without a workspace_rid. The implementation is clean and follows Python warning best practices. ✅ What's Working Well
❗ Critical Issues to Address1. Missing Test CoverageThe PR lacks tests for the warning behavior. This is essential for a user-facing change that generates warnings. Consider adding tests to verify:
2. Stacklevel Verification NeededThe stacklevel=2 setting should be tested across all call paths:
📝 Recommendations
🎯 Test Plan VerificationThe PR mentions several test scenarios that should be implemented as actual tests:
The core implementation is solid, but test coverage would significantly strengthen this change and ensure it works as expected for all users. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… RID Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each public entry point now emits the warning directly with stacklevel=2 so it points to user code. from_token skips its own warning when called internally via _workspace_warning_emitted=True. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…g_emitted Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default mode and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 631494b. Configure here.
…ng in e2e tests All creation paths delegate to from_token, so the warning only needs to live there. Removes _workspace_warning_emitted and the duplicate warnings in create() and from_profile(). E2e tests now assert the warning with pytest.warns rather than ignoring it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @seanmreidy's task —— View job Analysis Complete - Providing Comprehensive ReviewI've analyzed the PR and the feedback from multiple reviewers. Here's my comprehensive assessment of the current implementation and the issues that need to be addressed: 🚨 Critical Issues Identified1. Incorrect
|
as_user() calls from_token() internally and should not re-warn the user since the warning was already emitted when the original client was created. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @seanmreidy's task —— View job Comprehensive PR Review: Workspace RID Warning ImplementationAfter reviewing the current implementation and extensive feedback from multiple reviewers, I've identified several critical issues that need to be addressed before this PR can be merged safely. 🚨 Critical Issues Identified1. Incorrect
|

Summary
UserWarninginNominalClient.from_tokenwhen noworkspace_ridis providedhave a workspace RID specified will fail."
Background
get_default_workspacereturns a workspace if the user belongs to exactly one workspace, or ifthe org has a default workspace configured. This is the first step toward making
workspace_rida required parameter.Test plan
NominalClient.from_token(token, url)withoutworkspace_ridworkspace_ridis providedNominalClient.create(url, token)also triggers the warning (routes throughfrom_token)NominalClient.from_profiletriggers the warning when the profile has noworkspace_rid