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

bubble up python exceptions to response? #11

Open
ltalirz opened this issue Jun 2, 2021 · 2 comments
Open

bubble up python exceptions to response? #11

ltalirz opened this issue Jun 2, 2021 · 2 comments

Comments

@ltalirz
Copy link
Member

ltalirz commented Jun 2, 2021

While testing manually we realized that errors like forgetting to load the AiiDA profile are reported as an internal server errors

We may want to include this info in the response (although this may be a security concern)

@ltalirz
Copy link
Member Author

ltalirz commented Jun 3, 2021

as discussed in #17 (comment) we may want to do this by adopting the JSON API standard for the formatting of our responses and reporting errors in the errors field.

@ltalirz
Copy link
Member Author

ltalirz commented Jun 3, 2021

Note: the response format of the aiida-core rest api also includes the data field; amongst others:

{
  "data": {
    "nodes  ": [
      {
        "ctime": "Sun, 21 Jul 2019 11:45:52 GMT",
        "full_type": "data.dict.Dict.|",
        "id": 102618,
        "label": "",
        "mtime": "Sun, 21 Jul 2019 11:45:52 GMT",
        "node_type": "data.dict.Dict.",
        "process_type": null,
        "user_id": 4,
        "uuid": "a43596fe-3d95-4d9b-b34a-acabc21d7a1e"
      },
      {
        "ctime": "Sun, 21 Jul 2019 18:18:26 GMT",
        "full_type": "data.remote.RemoteData.|",
        "id": 102617,
        "label": "",
        "mtime": "Sun, 21 Jul 2019 18:18:26 GMT",
        "node_type": "data.remote.RemoteData.",
        "process_type": null,
        "user_id": 4,
        "uuid": "12f95e1c-69df-4a4b-9b06-8e69072e6108"
      }
    ]
  },
  "id": null,
  "method": "GET",
  "path": "/api/v4/nodes",
  "query_string": "limit=2&offset=8&orderby=-id",
  "resource_type": "nodes",
  "url": "http://localhost:5000/api/v4/nodes?limit=2&offset=8&orderby=-id",
  "url_root": "http://localhost:5000/"
}

These would be incompatible with the JSON API standard, which only allows data, errors, meta, jsonapi, links and included as top-level fields in the response.

@asle85 however mentions that these extra fields are currently not used in Materials Cloud explore & discover sections.

For the individual resources, however, JSON API also mandates a specific structure, see example

{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON:API paints my bikeshed!",
      "body": "The shortest article. Ever.",
      "created": "2015-05-22T14:56:29.000Z",
      "updated": "2015-05-22T14:56:28.000Z"
    }
}

I.e. we would need to

  • add a type field (would be backwards-compatible)
  • move the results into an attributes field (would be backwards-incompatible)

On the plus side, this would be how the graphql endpoint returns data

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

No branches or pull requests

1 participant