GET /notes type.id=X fails if limit <= number of results

Description

How to reproduce:

Using folio-snapshot environment and the type UUID for "General note":

Create at least one note with this typeId.

Run GET /notes with a query where type.id equals the "General note" UUID and the limit parameter is very high.  i.e. 

/notes?limit=100000&query=(type.id="d1de14b8-4bfd-4acc-b12b-545d3e20dc0a")

The return value indicates

"totalRecords": 1

Repeat the query with limit = totalRecords.

/notes?limit=1&query=(type.id="d1de14b8-4bfd-4acc-b12b-545d3e20dc0a")

Expected result: HTTP 200 OK and a meaningful response.

Actual result: HTTP 422 Unprocessable Entity

{     "errors": [        {      "message": "org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=generatedAlias2,role=org.folio.notes.domain.entity.NoteEntity.type,tableName=type,tableAlias=notetypeen2_,origin=note noteentity0_,columns={noteentity0_.type_id,className=org.folio.notes.domain.entity.NoteTypeEntity}}] [select count(generatedAlias0) from org.folio.notes.domain.entity.NoteEntity as generatedAlias0 left join generatedAlias0.type as generatedAlias1 inner join fetch generatedAlias0.type as generatedAlias2 where generatedAlias1.id=:param0]; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=generatedAlias2,role=org.folio.notes.domain.entity.NoteEntity.type,tableName=type,tableAlias=notetypeen2_,origin=note noteentity0_,columns={noteentity0_.type_id,className=org.folio.notes.domain.entity.NoteTypeEntity}}] [select count(generatedAlias0) from org.folio.notes.domain.entity.NoteEntity as generatedAlias0 left join generatedAlias0.type as generatedAlias1 inner join fetch generatedAlias0.type as generatedAlias2 where generatedAlias1.id=:param0]",             "type": "-1",             "code": "VALIDATION_ERROR"         }    ] }

Although folio-snapshot only has a single note (and folio-lotus has zero), I can reproduce this in our institution's environment with any limit <= the actual number of results.  The query succeeds with any limit > the actual number of results.

Affected versions: At least 3.0.4, 3.1.2, master.

Note: Apologies for any mistakes in Jira reporting conventions, this is my first bug report against FOLIO.

CSP Request Details

None

CSP Rejection Details

None

Potential Workaround

Use an absurdly high limit parameter. But that makes actual usage of limit & offset impossible.

Attachments

1
  • 22 Sep 2022, 05:01 AM

Checklist

hide

TestRail: Results

Activity

Show:

Valery_Pilko September 23, 2022 at 6:54 AM

Verified at Snapshot-2 env - works as expected.
See screencast in the task https://folio-org.atlassian.net/browse/FAT-2997 

Maccabee Levine September 22, 2022 at 12:36 PM

Looks good to me – thank you .

Sherzod Nurjonov September 22, 2022 at 5:01 AM

Tested on Snapshot, the issue is fixed:

Khalilah Gambrell September 20, 2022 at 1:13 PM

This story - addresses updating test cases only. Fix done with https://folio-org.atlassian.net/browse/FOLSPRINGB-72#icft=FOLSPRINGB-72.

Sherzod Nurjonov September 19, 2022 at 12:46 PM

Done

Details

Assignee

Reporter

Priority

Story Points

Sprint

Development Team

Spitfire

RCA Group

Lack of testing

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs
Created September 14, 2022 at 6:39 PM
Updated October 17, 2022 at 8:03 AM
Resolved September 26, 2022 at 3:10 PM
TestRail: Cases
TestRail: Runs