Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fields] Format error message only if params exist #6624

Merged
merged 1 commit into from
Jul 1, 2019

Conversation

michael-k
Copy link
Contributor

Description

This prevents exceptions when the error message contains %, but is not intended for formatting (more details are available in the linked issue). Django itself does the same: https://github.com/django/django/blob/6866c91b638de5368c18713fa851bfe56253ea55/django/core/exceptions.py#L168-L169

refs #6622

This prevents exceptions when the error message contains `%`, but is
not intended for formatting.  Django itself does the same:
https://github.com/django/django/blob/6866c91b638de5368c18713fa851bfe56253ea55/django/core/exceptions.py#L168-L169

Fixes encode#6622
err = DjangoValidationError('exc_msg', code='exc_code')
err = DjangoValidationError(
'exc_msg %s', code='exc_code', params=('exc_param',),
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to the issue, but there was no test that actually used params.

@bluetech
Copy link
Contributor

bluetech commented May 3, 2019

This looks good to me. The test would demonstrate my comment here: #6545 (comment)

@rpkilby
Copy link
Member

rpkilby commented May 6, 2019

Adding to the milestone. I'd like to consider this in coordination with #6545/#6644.

@rpkilby rpkilby added this to the 3.10 Release milestone May 6, 2019
@tomchristie
Copy link
Member

Yup, good stuff. 👍

@tomchristie tomchristie merged commit 79b2350 into encode:master Jul 1, 2019
@michael-k michael-k deleted the format-error-message branch July 1, 2019 15:25
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
This prevents exceptions when the error message contains `%`, but is
not intended for formatting.  Django itself does the same:
https://github.com/django/django/blob/6866c91b638de5368c18713fa851bfe56253ea55/django/core/exceptions.py#L168-L169

Fixes encode#6622
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
This prevents exceptions when the error message contains `%`, but is
not intended for formatting.  Django itself does the same:
https://github.com/django/django/blob/6866c91b638de5368c18713fa851bfe56253ea55/django/core/exceptions.py#L168-L169

Fixes encode#6622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants