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 meta.query.representation and remove /optimade in base URLs #201

Merged
merged 6 commits into from Mar 5, 2020

Conversation

CasperWA
Copy link
Member

@CasperWA CasperWA commented Mar 2, 2020

Fixes #199
Closes #197

Concerning meta.query.representation (#199)

For #199 a regex is now used to match the version part of the URL path.
Note, however that the regex only recognizes the form /vMAJOR[.MINOR[.PATCH]]. So if anything other is passed, the meta.query.representation value will return the full URL path.

E.g., for a server with version 0.10.1 running at https://example.org, a request to: https://example.org/vTest/structures will return a 404 and a JSON response (as expected) with an error object under the top-level errors field, as well as the standard meta fields, where meta.query.representation will be the full path, i.e., /vTest/structures?, where it maybe should be simply /structures?. However, I think this is fine?

Otherwise, for the same server (again, running version 0.10.1 at https://example.org) a request to: https://example.org/v1.0/structures will return the same response, essentially, with the exception of the value of meta.query.representation, which will be /structures?.

For me this is fine, what do you think?

Concerning the removal of /optimade from the base URL (#197)

This has been removed throughout the code base, where I could match /optimade and it made sense.

Addtional

The validator GH Action did not support setting path to /, this PR fixes this, which is indeed crucial concerning the removal of /optimade.

@codecov
Copy link

codecov bot commented Mar 2, 2020

Codecov Report

Merging #201 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #201      +/-   ##
==========================================
+ Coverage   86.62%   86.67%   +0.04%     
==========================================
  Files          39       39              
  Lines        1854     1853       -1     
==========================================
  Hits         1606     1606              
+ Misses        248      247       -1     
Flag Coverage Δ
#unittests 86.67% <75.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98c9b4b...be49f53. Read the comment docs.

@CasperWA CasperWA force-pushed the fix_199_representation branch 3 times, most recently from b7fe967 to 95c6602 Compare March 4, 2020 17:30
Note: It is still in some examples.
Add test for empty path input for validator action.
Use {} for bash variables to properly distinguish between consequtive
variables.
ml-evs
ml-evs previously approved these changes Mar 5, 2020
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

No complaints or comments from me! Cheers @CasperWA.

E.g., for a server with version 0.10.1 running at https://example.org, a request to: https://example.org/vTest/structures will return a 404 and a JSON response (as expected) with an error object under the top-level errors field, as well as the standard meta fields, where meta.query.representation will be the full path, i.e., /vTest/structures?, where it maybe should be simply /structures?. However, I think this is fine?

I think this is fine! In future, we could potentially make the error message more informative by alerting the client that it was the version number specifically that was wrong.

@ml-evs
Copy link
Member

ml-evs commented Mar 5, 2020

One other comment, actually: previously the unversioned URL i.e. localhost:5000/optimade would redirect to the landing page. Do we want to continue that behaviour, i.e. have localhost:5000 redirect to the landing page?

@ml-evs ml-evs self-requested a review March 5, 2020 14:46
@ml-evs
Copy link
Member

ml-evs commented Mar 5, 2020

I also note that the landing page router is currently untested, I'm happy to make that a separate PR pending this decision.

@CasperWA
Copy link
Member Author

CasperWA commented Mar 5, 2020

I also note that the landing page router is currently untested, I'm happy to make that a separate PR pending this decision.

Yup, see also #104

@CasperWA
Copy link
Member Author

CasperWA commented Mar 5, 2020

One other comment, actually: previously the unversioned URL i.e. localhost:5000/optimade would redirect to the landing page. Do we want to continue that behaviour, i.e. have localhost:5000 redirect to the landing page?

Good question. I think this makes sense, yes.

@CasperWA CasperWA merged commit 24637f2 into master Mar 5, 2020
@CasperWA CasperWA deleted the fix_199_representation branch March 5, 2020 15:18
@CasperWA CasperWA mentioned this pull request Mar 5, 2020
CasperWA added a commit that referenced this pull request Mar 6, 2020
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)
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.

meta/query/representation value not cutting off version properly Drop '/optimade' from paths in openapi.json
2 participants