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
Workaround for URL encoding in pydantic 1.10 #1317
Workaround for URL encoding in pydantic 1.10 #1317
Conversation
Bumps [numpy](https://github.com/numpy/numpy) from 1.23.1 to 1.23.2. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](numpy/numpy@v1.23.1...v1.23.2) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [aiida-core](https://github.com/aiidateam/aiida-core) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/aiidateam/aiida-core/releases) - [Changelog](https://github.com/aiidateam/aiida-core/blob/main/CHANGELOG.md) - [Commits](aiidateam/aiida-core@v2.0.2...v2.0.3) --- updated-dependencies: - dependency-name: aiida-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.3.9 to 8.4.0. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](squidfunk/mkdocs-material@8.3.9...8.4.0) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [pydantic](https://github.com/samuelcolvin/pydantic) from 1.9.1 to 1.9.2. - [Release notes](https://github.com/samuelcolvin/pydantic/releases) - [Changelog](https://github.com/pydantic/pydantic/blob/master/HISTORY.md) - [Commits](pydantic/pydantic@v1.9.1...v1.9.2) --- updated-dependencies: - dependency-name: pydantic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.79.0 to 0.79.1. - [Release notes](https://github.com/tiangolo/fastapi/releases) - [Commits](tiangolo/fastapi@0.79.0...0.79.1) --- updated-dependencies: - dependency-name: fastapi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.4.0 to 8.4.1. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](squidfunk/mkdocs-material@8.4.0...8.4.1) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.14.5 to 2.15.0. - [Release notes](https://github.com/PyCQA/pylint/releases) - [Commits](pylint-dev/pylint@v2.14.5...v2.15.0) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.79.1 to 0.81.0. - [Release notes](https://github.com/tiangolo/fastapi/releases) - [Commits](tiangolo/fastapi@0.79.1...0.81.0) --- updated-dependencies: - dependency-name: fastapi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 8.4.1 to 8.4.2. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](squidfunk/mkdocs-material@8.4.1...8.4.2) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [uvicorn](https://github.com/encode/uvicorn) from 0.18.2 to 0.18.3. - [Release notes](https://github.com/encode/uvicorn/releases) - [Changelog](https://github.com/encode/uvicorn/blob/master/CHANGELOG.md) - [Commits](encode/uvicorn@0.18.2...0.18.3) --- updated-dependencies: - dependency-name: uvicorn dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [jarvis-tools](https://github.com/usnistgov/jarvis) from 2022.7.17 to 2022.8.27. - [Release notes](https://github.com/usnistgov/jarvis/releases) - [Commits](https://github.com/usnistgov/jarvis/commits/v2022.08.27) --- updated-dependencies: - dependency-name: jarvis-tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [pydantic](https://github.com/pydantic/pydantic) from 1.9.2 to 1.10.0. - [Release notes](https://github.com/pydantic/pydantic/releases) - [Changelog](https://github.com/pydantic/pydantic/blob/main/HISTORY.md) - [Commits](pydantic/pydantic@v1.9.2...v1.10.0) --- updated-dependencies: - dependency-name: pydantic dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## master #1317 +/- ##
=======================================
Coverage 90.90% 90.90%
=======================================
Files 72 72
Lines 4364 4366 +2
=======================================
+ Hits 3967 3969 +2
Misses 397 397
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
…/optimade-python-tools into ci/update-dependencies
@@ -6,6 +6,22 @@ | |||
|
|||
import pytest | |||
|
|||
import re |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not entirely sure what is causing this bug to trigger in these dependency updates. Could you perhaps make a separate PR that just includes this test, so we can see if it fails? I'd also recommend just sticking it at the end of tests.servers.routers.test_structures
rather than in the test_utils.py
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug is triggered by pydantic 1.10. Basically, pydantic now also encodes the query part of the url.
That was however already done in our code with urllib.parse.encode. So we have to turn of one of the two.
See more info at https://github.com/pydantic/pydantic/issues/3061and pydantic/pydantic#4224
And this bug report: pydantic/pydantic#4458
It looks like they are already working on a fix : pydantic/pydantic#4461
Although there is still some discussion about whether it should be implemented.
There are also still some problems with spaces. Not all browsers can handle a + sign correctly. So my solution may not work for everybody. I also tried to keep the spaces, but then I get an error:
status | "500" |
---|---|
code | "value_error.url.extra" |
title | "ValidationError" |
detail | "URL invalid, extra characters found after valid URL: ' HAS "Ac"&page_limit=2&page_offset=2'" |
source | |
pointer | "/next" |
So maybe we should wait to see if it gets accepted.
This test mostly checks whether the next link is in a format that will be handled correctly by pydantic 1.10.
It does not test whether the next link is valid. For that, we should use _test_page_limit
from validator.py
I deliberately put it in test_utils.py as it applies to all endpoints and not just structures as the affected code is also in utils.py. I can use the EntryResponseMany class instead of the StructureResponseMany class if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's wait. It looks like the main author is working on a fix (as of 30 mins ago).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it would be useful to add the test to test_structures.py
in a separate PR though.
urlencoded = urllib.parse.urlencode( | ||
query, doseq=True, quote_via=dummy_quote | ||
) # it seems the url is also quoted at a later stage so we should not quote it here, hence the dummy_quote. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urlencoded = urllib.parse.urlencode( | |
query, doseq=True, quote_via=dummy_quote | |
) # it seems the url is also quoted at a later stage so we should not quote it here, hence the dummy_quote. | |
urlencoded = urllib.parse.urlencode( | |
query, doseq=True, quote_via=lambda x, *_: x.replace(" ", "+") | |
) |
is probably a bit cleaner. I had a look at the built-in urllib.parse.quote
method, not sure how it differs from this when passed to quote_via
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your suggestion is indeed cleaner. I'll use a lambda function instead.
Now that pydantic 1.10.2 is out and #1316 is passing, I think this can be closed. |
I am trying to solve the issues in PR #1316 with this PR, so this PR can be merged instead of PR #1316.