INTER-2250: Accept unknown enum values#200
Open
erayaydin wants to merge 6 commits into
Open
Conversation
When the API introduces new enum values, the SDK threw `ApiException` or `ValidationError` during deserialization instead of accepting the value gracefully. Related-Task: INTER-2250
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Use Union[Enum, str] return type and str(data) to satisfy mypy Related-Task: INTER-2250
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the SDK’s deserialization behavior so newly introduced API enum values don’t raise ValidationError and can be preserved instead.
Changes:
- Add tests that assert unknown/new enum values are accepted and round-trip through model deserialization.
- Loosen enum validation in generated models and deserialization, and introduce enum
_missing_handling for graceful unknown values. - Update OpenAPI generator templates so future generated code also accepts unknown enum values.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_unknown_enum_values.py | Adds regression tests for unknown enum values across several models/fields. |
| template/model_generic.mustache | Removes strict enum validation logic from generated model validators. |
| template/model_enum.mustache | Introduces enum template with _missing_ hook for unknown values. |
| template/api_client.mustache | Changes enum deserialization behavior in the generated API client. |
| fingerprint_server_sdk/api_client.py | Changes runtime enum deserialization behavior in ApiClient. |
| .changeset/accept-unknown-enum-values.md | Adds a release-note style entry for the change. |
| fingerprint_server_sdk/models/vpn_confidence.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/tampering_confidence.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/search_events_vpn_confidence.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/search_events_sdk_platform.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/search_events_rare_device_percentile_bucket.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/search_events_incremental_identification_status.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/search_events_bot.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/search_events_bot_info.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/sdk.py | Removes strict enum validation for platform. |
| fingerprint_server_sdk/models/rule_action_type.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/rare_device_percentile_bucket.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/proxy_details.py | Removes strict enum validation for proxy_type. |
| fingerprint_server_sdk/models/proxy_confidence.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/proximity.py | Removes strict enum validation for precision_radius. |
| fingerprint_server_sdk/models/incremental_identification_status.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/error_code.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/bot_result.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/bot_info.py | Removes strict enum validation for identity and confidence. |
| fingerprint_server_sdk/models/bot_info_identity.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/bot_info_confidence.py | Adds _missing_ to accept unknown enum values. |
| fingerprint_server_sdk/models/bot_info_category.py | Adds _missing_ to accept unknown enum values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use str(value) for \_name\_ in \_missing\_ so enum member names are always strings. Restore ValueError -> ApiException wrapping. Related-Task: INTER-2250
Contributor
🚀 Following releases will be created using changesets from this PR:@fingerprint/python-sdk@9.3.1Patch Changes
|
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.
Summary
When the API introduces new enum values (e.g., a new proxy type), the SDK threw
ValidationErrorduring deserialization instead of accepting the value gracefully