Add email_verification_id field to BaseRequestException#1
Open
devin-ai-integration[bot] wants to merge 5 commits intomainfrom
Open
Add email_verification_id field to BaseRequestException#1devin-ai-integration[bot] wants to merge 5 commits intomainfrom
devin-ai-integration[bot] wants to merge 5 commits intomainfrom
Conversation
Fixes workos#309 When authenticate_with_password() raises an AuthorizationException for an unverified email, the API response includes an email_verification_id field. This field is now properly extracted and accessible on the exception object, eliminating the need to manually parse the response JSON. Co-Authored-By: Deep Singhvi <deep@buildwithfern.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…xception - Created EmailVerificationRequiredException subclass of AuthorizationException - Added email_verification_id field specific to this exception type - Updated HTTP client to detect email_verification_required error code and raise specific exception - Added tests for both the new exception and to verify regular AuthorizationException still works - All 370 tests pass Co-Authored-By: Deep Singhvi <deep@buildwithfern.com>
* Update version to 5.31.0 * Remove unused mock session from test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes workos#309
Introduces a new
EmailVerificationRequiredExceptionthat extendsAuthorizationExceptionto provide direct access to theemail_verification_idfield when authentication fails due to unverified email.Changes
New Exception Class (
workos/exceptions.py):EmailVerificationRequiredExceptionas a subclass ofAuthorizationExceptionemail_verification_idfrom the error response JSONHTTP Client Logic (
workos/utils/_base_http_client.py):_maybe_raise_error_by_status_codeto detect the specific error codecode: "email_verification_required", raises the new specific exceptionAuthorizationException(preserves existing behavior)Tests (
tests/test_sync_http_client.py):EmailVerificationRequiredExceptionis raised with correct fieldsAuthorizationExceptionstill works for other 403 errorsAuthorizationException(maintains backward compatibility)Key Design Decisions
EmailVerificationRequiredExceptionextendsAuthorizationExceptionrather than adding fields to the base class, providing better type safety and semantic clarityAuthorizationExceptionwill continue to workcodefield from the API response to identify this specific error conditionReview Checklist
"email_verification_required"is the correct/only error code for this scenarioBefore/After
Before:
After:
All 370 tests pass.
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, documentation should cover:
EmailVerificationRequiredExceptionis raisedemail_verification_idfieldLink to Devin run: https://app.devin.ai/sessions/ec6b5bc71374406895201f8407f1f73c
Requested by: Deep Singhvi (@dsinghvi)