Skip to content

Handle failed requests for available controlled terms gracefully #54

@alyssadai

Description

@alyssadai

Questions:

  • should the response format be the same as for partial-success query results, e.g. with a section for the errors encountered?
  • should "partial-success" terms fetching be allowed?

Decision:
If query tool fails to get terms from a node:

  • For now, just return terms available from nodes that are reachable/don't error out
  • Should keep the same response shape as for cohort queries e.g.:
{
  "nb:Assessment": [
    {
      "TermURL": "cogatlas:trm_56a9137d9dce1",
      "Label": "behavioral approach/inhibition systems"
    },
    {
      "TermURL": "cogatlas:trm_55a6a8e81b7f4",
      "Label": "Barratt Impulsiveness Scale"
    },
    ...
}

to:

{
  "errors": [{}] ...
  "responses":
  {
    "nb:Assessment": [
      {
        "TermURL": "cogatlas:trm_56a9137d9dce1",
        "Label": "behavioral approach/inhibition systems"
      },
      {
        "TermURL": "cogatlas:trm_55a6a8e81b7f4",
        "Label": "Barratt Impulsiveness Scale"
      },
      ...
  },
  "nodes_response_status": "..."
}

When request to all nodes fail:

{
  "errors": [<all errors>] ...
  "responses":
  {
    "nb:Assessment": []
  },
  "nodes_response_status": "fail"
}

Steps to implement:

  • Switch to async requests to nodes
  • Add error responses to list
  • Add new response model for combined attribute response
  • Rename tests of partial success cohort queries to be more specific
  • Consider refactoring mixed-status JSONResponse into its own class/function?
  • When requests to all nodes fail, should return "responses": {<data_element_URI>: []}

Metadata

Metadata

Assignees

Labels

releasedThis issue/pull request has been released.

Type

No type

Projects

Status

Review - Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions