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 errors parsing IDs that contain slashes #183
Conversation
3d48734
to
1546bd5
Compare
So looking into this issue a bit, I've found that the issue is that we are not enclosing the value in quotes ( Edit: Tried to make this comment long time ago - GitHub finally worked. |
Codecov Report
@@ Coverage Diff @@
## master #183 +/- ##
=========================================
Coverage ? 86.62%
=========================================
Files ? 39
Lines ? 1854
Branches ? 0
=========================================
Hits ? 1606
Misses ? 248
Partials ? 0
Continue to review full report at Codecov.
|
So I've "hacked" the grammar to allow for un-quoted |
From Skype conversation with @ml-evs (all from me): it seems the issue is (simply) that to be recognized as an escaped string, it needs to be in quotations I've been testing it further, implementing a separate grammar that adds an |
Thanks for this fix @CasperWA, it seems sensible to me! I'd like to test that this works on my own server later on, as the initial problem I had was an internal server issue where it could not return documents with this ID in |
This does indeed fix the error I was getting @CasperWA, but I see what you mean about treating ID's on a separate footing. A small change to |
The fix in the router is quite straightforward, but for me it doesn't solve the underlying question: Should |
I'd rather fix it in the router, so I'll remove the grammar changes. |
88bc3b9
to
877ee29
Compare
Sure. Following the discussion in Materials-Consortia/OPTIMADE#259 we should however be able to not have to enclose the value in quotation marks ... But this of course shouldn't have to actually result in a grammar change for the Edit: I think I mixed up some issues with this comment - never mind, you do you 😅 |
877ee29
to
1edff4b
Compare
95da19f
to
4c85295
Compare
Since id values may be given without being an escaped string (i.e., without quotation marks `"`) this needs to be taken into account in the grammar. Up to this point, the only allowed values for id (without quotation marks) were as a "property", i.e., r"\._[a-z][0-9]", so no capital letters, nor any special characters, e.g., like `/`.
This commit effectively reverts 1546bd. Co-Authored-By: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
4c85295
to
7ad0c7b
Compare
I have just added tests (they should currently fail) for the |
Maybe this is for a different PR - I will revert and create a new PR |
7ad0c7b
to
e80daf5
Compare
I'm happy with this when you are @CasperWA, we can make the required changes later based on the spec-level decision. |
Up to v0.6.0. **New features**: - GitHub Action validator that runs `optimade_validator` for a locally running OPTiMaDe server (#191, @CasperWA, tested by @ml-evs) - Support filter queries for `HAS ALL`, `HAS ANY` and `HAS ONLY` and value lists on MongoDB backends (#173, @ml-evs) Note: `OPERATOR` use in value lists are still _not_ supported. - Debug mode. Start the server in debug mode to enable `debug` log-level in `uvicorn` and get a full Python traceback in the JSON response (#190, @CasperWA) - Add testing of mandatory `filter` queries to `optimade_validator` (#205, @ml-evs) **Updates**: - Allow Cross-Origin requests from anywhere (`*`), i.e., enable CORS for both servers (#194, @CasperWA) - Updates to models (correct misspelling, more transparent model class naming, streamline models with respect to python class inheritance, update field descriptions) (#195, @CasperWA) - API change: Rename `optimade.models.toplevel.py` to `optimade.models.responses.py` (#195, @CasperWA) - Update dependencies to newest versions (as of 02.03.2020) (#202, #196, @CasperWA) - Move imports from `starlette` to `fastapi`, where possible (#202, @ml-evs) - Remove custom middleware to redirect slashed URLs in favor of `starlette` implementation (#202, @ml-evs) - CI tests are now performed with a real MongoDB in the backend. CI tests are also performed with a `mongomock` backend for the tests in `server/test_middleware.py`, `server/test_server_validation.py`, and `server/test_config.py` (#196, @ml-evs, additional testing by @CasperWA ) - Remove `/optimade` from base URLs. This was especially important for the OpenAPI schema (#201, #216, @CasperWA, @ml-evs) - Check integrity of query part of the raw URL using a custom middleware (#209, @CasperWA) - New `optimade/server/exceptions.py` to contain custom `HttpException`s, moved `BadRequest` here (#209, @CasperWA) - Pattern and regex testing for `data.available_api_versions` parts in `/info` endpoint and fix tests for the same (#211, @CasperWA) - Restructure import of test data for regular server (#212, @shyamd) **Bug fixes**: - New retrieval URL for Materials-Consortia's list of providers (#187, @CasperWA) - Skip local `HAS ONLY` tests with a `mongomock` backend, since v3.19.0 does not support these (#206, @ml-evs) - Resource ID's can now contain slashes (`/`) (#183, @ml-evs, @CasperWA) - Remove _valid_ version part of base URL in `meta.query.representation` (#201, @CasperWA)
Hopefully this will eventually close #181...
This PR so far just adds tests that should pass and currently don't. When filtering on included data (which is done by default) any "/" in the ID (totally allowed under spec) will throw a lark parser error, e.g.