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

Fix #1621: Do not crash when encountering unexpected data in the request #1624

Merged
merged 1 commit into from
May 23, 2022

Conversation

matthiask
Copy link
Member

No description provided.

else:
return [(k, variable.getlist(k)) for k in sorted(variable)]
except TypeError:
return [(f"<{source}>", variable)]
Copy link
Member

Choose a reason for hiding this comment

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

Since the wrapping call already has this associated with the attribute on the request (get, post, files), I don't think we need to use the source. I think using an empty string or something constant will be more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that's a good point. I have pushed an update but I haven't tested the update (yet)

@matthiask matthiask force-pushed the mk/1621 branch 3 times, most recently from 252f96a to a84302c Compare May 19, 2022 06:05
@matthiask
Copy link
Member Author

image

Here's how this could look. I broke get_sorted_request_variable on purpose to show cookies and query parameters as a raw block instead of as a table for the screenshot, but the code should still behave the same except if encountering some malformed data in request variables.

@matthiask
Copy link
Member Author

@FinnGu I'd appreciate your input and/or testing if you have a way to do this.

@FinnGu
Copy link

FinnGu commented May 20, 2022

@FinnGu I'd appreciate your input and/or testing if you have a way to do this.

Alright, setting up some tests on my end. And thank you for your quick PR!

@FinnGu
Copy link

FinnGu commented May 20, 2022

@matthiask I just recently started using the DDT, so I don't know about all of its features. But for my use case, everything works flawlessly! I am now able to raise ParseErrors, ValidationErrors and basically all other exceptions that I am used to, without the DDT interfering with DRF ❤️

@matthiask
Copy link
Member Author

Thanks! Good to hear.

@matthiask matthiask merged commit c5f691f into main May 23, 2022
@matthiask matthiask deleted the mk/1621 branch May 23, 2022 07:20
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.

3 participants