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

Creation of related entities attempted when not specified to be included #387

Closed
1 task
VKTB opened this issue Nov 15, 2022 · 0 comments · Fixed by #390
Closed
1 task

Creation of related entities attempted when not specified to be included #387

VKTB opened this issue Nov 15, 2022 · 0 comments · Fixed by #390
Assignees
Labels
bug Something isn't working expands-search-api Issues relating to the ExPaNDS Search API section of this repo

Comments

@VKTB
Copy link
Contributor

VKTB commented Nov 15, 2022

Description:
When using the Search API against ICAT < 5.0 where the ICAT mapping for the instrument field in the Dataset entity is investigation.investigationInstruments.instrument, the following error is returned to the user when sending a GET request to the /datasets endpoint that has a filter to include the instrument entity.

Error response:

{
    "error": {
        "message": "1 validation error for Document\ntype\n  field required (type=value_error.missing)",
        "name": "ValidationError",
        "statusCode": 500
    }
}

Request URL:

http://localhost:5000/search-api/datasets?filter={  "include": [    {      "relation": "instrument"    }  ]}

From the error, it is clear that the Search API is attempting to create a Document entity despite this related entity not being specified to be included. The ICAT mapping for the documents field in the Dataset entity is investigation and because the data for the instrument field is retrieved via the investigation entity, it means that the data returned from ICAT includes investigation data, see response below.

Click here for ICAT data

{
  "description": "Many last prepare small. Maintain throw hope parent.\nEntire soon option bill fish against power.\nRather why rise month shake voice.",
  "name": "DATASET 1",
  "createTime": "2002-11-27 06:20:36+00:00",
  "endDate": "2000-07-05 00:00:00+01:00",
  "investigation": {
    "summary": "Season identify professor happen third. Beat professional blue clear style have. Light final summer.",
    "name": "INVESTIGATION 1",
    "createTime": "2002-11-27 06:20:36+00:00",
    "endDate": "2000-07-09 00:00:00+01:00",
    "doi": "0-449-78690-0",
    "createId": "user",
    "title": "Including spend increase ability music skill former. Agreement director concern once technology sometimes someone staff.\nSuccess pull bar. Laugh senior example.",
    "visitId": "42",
    "modId": "user",
    "startDate": "2000-04-03 00:00:00+01:00",
    "releaseDate": "2000-07-05 00:00:00+01:00",
    "modTime": "2005-04-30 19:41:49+01:00",
    "investigationInstruments": [
      {
        "modId": "user",
        "modTime": "2005-04-30 19:41:49+01:00",
        "createTime": "2002-11-27 06:20:36+00:00",
        "instrument": {
          "fullName": "Some design study memory. Against happy summer report exist through.",
          "description": "Sea customer home food important.\nAsk feel sometimes move individual five evening. May moment chance trial for foreign attention.\nLaw hair score herself threat back often. Care model offer yeah.",
          "name": "INSTRUMENT 8",
          "createTime": "2018-12-25 10:35:30+00:00",
          "type": "8",
          "createId": "user",
          "url": "https://www.wilson.com/",
          "facility": {
            "fullName": null,
            "description": "Lorem ipsum light source",
            "name": "LILS",
            "createTime": "2002-11-27 06:20:36+00:00",
            "createId": "user",
            "url": null,
            "daysUntilRelease": 10,
            "modId": "user",
            "modTime": "2005-04-30 19:41:49+01:00",
            "id": 1
          },
          "investigationInstruments": [],
          "modId": "user",
          "modTime": "2018-06-15 07:30:33+01:00",
          "pid": null,
          "id": 8
        },
        "createId": "user",
        "id": 1
      }
    ],
    "id": 1
  },
  "doi": "0-449-78690-0",
  "createId": "user",
  "complete": true,
  "modId": "user",
  "startDate": "2000-05-07 00:00:00+01:00",
  "modTime": "2005-04-30 19:41:49+01:00",
  "location": "/international/subject.tiff",
  "id": 1
}

At the moment, when the Search API sees data for related entities in the ICAT data response (investigation in this case), it attempts to create corresponding Search API-related entities (document in this case) even if they are not specified to be included.

Acceptance criteria:

  • The Search API should not attempt to create related entities that are not specified to be included when ICAT data for them is returned
@VKTB VKTB added bug Something isn't working expands-search-api Issues relating to the ExPaNDS Search API section of this repo labels Nov 15, 2022
VKTB added a commit that referenced this issue Nov 16, 2022
@VKTB VKTB self-assigned this Nov 16, 2022
@VKTB VKTB closed this as completed in #390 Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working expands-search-api Issues relating to the ExPaNDS Search API section of this repo
Projects
None yet
1 participant