Opened 15 months ago
Closed 12 months ago
#34818 closed Bug (fixed)
GenericIPAddressField ValidationError incorrect message when both protocols present
Reported by: | minusf | Owned by: | Parth Verma |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
It seems that the invalid
code for GenericIPAddressField
models gets clobbered when both protocols are present in a model:
class Site(models.Model): ipv6 = models.GenericIPAddressField(protocol="IPv6") ipv4 = models.GenericIPAddressField(protocol="IPv4")
>>> site = Site(ipv6="6", ipv4="4") >>> site.full_clean() Traceback (most recent call last): File "<console>", line 1, in <module> File "/src/tmp/ip_bug/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1502, in full_clean raise ValidationError(errors) django.core.exceptions.ValidationError: {'ipv6': ['Enter a valid IPv4 address.'], 'ipv4': ['Enter a valid IPv4 address.']}
sometimes the other message wins:
ValidationError: {'ipv6': ['Enter a valid IPv6 address.'], 'ipv4': ['Enter a valid IPv6 address.']}
p.s. not sure about the component, perhaps could be "Database Layer: Models" or "Error reporting"?
Change History (13)
comment:1 by , 15 months ago
Description: | modified (diff) |
---|
comment:2 by , 15 months ago
Component: | Error reporting → Database layer (models, ORM) |
---|---|
Owner: | set to |
Triage Stage: | Unreviewed → Accepted |
follow-up: 4 comment:3 by , 15 months ago
Hi! This is my first open source contribution attempt! I was able to recreate the error and find a hacky solution to it. But it involves deletion of code and as a beginner, I am not too confident in that! I'd like to take some time and put more efforts to this issue. Any suggestions would be highly welcome!
comment:4 by , 15 months ago
Replying to Jay Prasad:
Hi! This is my first open source contribution attempt! I was able to recreate the error and find a hacky solution to it. But it involves deletion of code and as a beginner, I am not too confident in that! I'd like to take some time and put more efforts to this issue. Any suggestions would be highly welcome!
Hello Jay, thanks for your contribution! Do you have a PR with your fix?
comment:5 by , 14 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 14 months ago
Has patch: | set |
---|
comment:7 by , 14 months ago
Patch needs improvement: | set |
---|
comment:8 by , 12 months ago
Owner: | changed from | to
---|
follow-up: 10 comment:9 by , 12 months ago
Owner: | changed from | to
---|
Hi
I was working on the bug fix and had pushed a patch. I was waiting on the approval on the direction of the fix to finalize the patch. Having received it just this week I’d like to be reassigned to this so that I can take this to completion
comment:10 by , 12 months ago
Replying to Parth Verma:
Hi
I was working on the bug fix and had pushed a patch. I was waiting on the approval on the direction of the fix to finalize the patch. Having received it just this week I’d like to be reassigned to this so that I can take this to completion
I left a comment without any reply from you almost 2 months ago.
comment:11 by , 12 months ago
I thought that comment was for claudep. Anyway, sorry for the confusion. I’ll raise the final patch this weekend
comment:12 by , 12 months ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Looks like a long-standing bug. A classic error where a class attribute is shared and modified by different instances. Thanks for the report.