fix: map missing_required_field to MissingRequiredFieldsError#237
Open
mayankbohradev wants to merge 1 commit into
Open
fix: map missing_required_field to MissingRequiredFieldsError#237mayankbohradev wants to merge 1 commit into
mayankbohradev wants to merge 1 commit into
Conversation
The Resend API and docs emit singular missing_required_field on 422 responses. The SDK only registered the plural key, so callers catching MissingRequiredFieldsError never matched real API errors.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #237 +/- ##
===========================================
+ Coverage 82.66% 95.96% +13.29%
===========================================
Files 4 61 +57
Lines 75 3219 +3144
===========================================
+ Hits 62 3089 +3027
- Misses 13 130 +117 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
missing_required_field(singular) so it raisesMissingRequiredFieldsError.missing_required_fields(plural) as a backward-compatible alias.Why
Resend error docs define
missing_required_field(singular). The Python SDKERRORSmap only hadmissing_required_fields(plural), so a real 422 withname: "missing_required_field"fell through to genericResendError. Callers catchingMissingRequiredFieldsErrornever matched.Validation (before / after)
Reproducible with the public mapper (no network):
Expected after this PR:
Same path as
Request.perform/AsyncRequest.perform, which passdata["name"]intoraise_for_code_and_type.Testing
pytest tests/exceptions_test.py(16 passed)mypy resend/exceptions.py tests/exceptions_test.pyflake8 --max-line-length=130 ./resend/exceptions.pySummary by cubic
Correctly raises
MissingRequiredFieldsErrorfor 422 responses with the documentedmissing_required_fieldname, so callers catching this exception now match real API errors.missing_required_fieldin the 422ERRORStable; keepmissing_required_fieldsas a legacy alias.raise_for_code_and_typedocstring.Written for commit e3a1e13. Summary will update on new commits.