fix(schemas): use EmailStr for email fields in user create schemas#946
Open
armorbreak001 wants to merge 3 commits into
Open
fix(schemas): use EmailStr for email fields in user create schemas#946armorbreak001 wants to merge 3 commits into
armorbreak001 wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #946 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 369 369
Lines 15539 15539
Branches 503 503
=========================================
Hits 15539 15539 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ibility The default schemathesis email strategy can produce internationalized addresses with non-ASCII domain characters (e.g. Korean TLDs) that pydantic.EmailStr rejects per RFC 5321. This causes 422 validation error responses during fuzz testing that don't match the OpenAPI success-response schema, making schemathesis report spurious failures. Register a strict ASCII email format strategy that generates only RFC-compliant addresses, ensuring EmailStr accepts all fuzz inputs and the existing response-schema checks remain valid.
for more information, see https://pre-commit.ci
Member
|
@Stranger6667 do you have an experience integrating ? |
Contributor
|
Probably to change |
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.
Problem
UserCreateSchema and SimpleUserCreateSchema use
email: str, which accepts any string — including invalid email addresses. This means garbage data passes Pydantic validation and either causes a DB-level error or gets stored as-is, with no user-facing 422 response explaining the format requirement.The underlying Django model uses
EmailField(unique=True), so the serializer should enforce the same validation at the API boundary.Fix
Change
email: str→email: pydantic.EmailStrin both schemas:server/apps/model_fk/serializers.py(UserCreateSchema)server/apps/model_simple/serializers.py(SimpleUserCreateSchema)This matches the existing pattern already used in the project's tests and examples (
pydantic.EmailStr).Closes #945