Bug 35658

Summary: Typo in /patrons/:patron_id/holds
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: REST APIAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, lucas, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35614
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.02,23.05.08
Circulation function:
Bug Depends on: 34333    
Bug Blocks:    
Attachments: Bug 35658: Fix misaligned collectionFormat in patron_holds.yaml

Description Tomás Cohen Arazi (tcohen) 2023-12-28 13:11:29 UTC
Bug 34333 added the ability to embed cancellation requests information on the holds endpoint, but the `collectionFormat` attribute got misaligned, making the feature unusable.

This is hard to catch. Steps to reproduce:
1. Open your favourite REST tool
2. Make this request:

GET http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/42/holds
x-koha-embed: cancellation_requested

=> SUCCESS: Probably empty result, but not an error

3. Make this change:

 $ git diff
diff --git a/api/v1/swagger/paths/patrons_holds.yaml b/api/v1/swagger/paths/patrons_holds.yaml
index e8e1335a87d..c70d3359c41 100644
--- a/api/v1/swagger/paths/patrons_holds.yaml
+++ b/api/v1/swagger/paths/patrons_holds.yaml
@@ -24,6 +24,7 @@
           type: string
           enum:
             - cancellation_requested
+            - pickup_library
           collectionFormat: csv
     produces:
       - application/json

4. Restart plack:
   $ ktd --shell
  k$ koha-plack --restart kohadev
5. Repeat 2
=> SUCCESS: Same thing
6. Amend the request like this:

GET http://kohadev-intra.myDNSname.org:8081/api/v1/patrons/42/holds
x-koha-embed: cancellation_requested,pickup_library

=> FAIL: You get this, which is weird because it matches exactly what's in the x-koha-embed `enum`:

{
    "errors": [
        {
            "message": "Not in enum list: cancellation_requested, pickup_library.",
            "path": "/x-koha-embed/0"
        }
    ],
    "status": 400
}


This is related to bug 35614.
Comment 1 Tomás Cohen Arazi (tcohen) 2023-12-28 13:21:00 UTC
Created attachment 160353 [details] [review]
Bug 35658: Fix misaligned collectionFormat in patron_holds.yaml

This patch fixes a silly typo.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 2 Jonathan Druart 2024-01-03 15:51:43 UTC
Upping severity, I lost hours on this...
Comment 3 Katrin Fischer 2024-01-03 22:27:22 UTC
I am sorry, holidays got in the way - it's next on my 'push list' already.
Comment 4 Katrin Fischer 2024-01-04 15:53:46 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 5 Fridolin Somers 2024-01-08 14:06:08 UTC
Pushed to 23.11.x for 23.11.02
Comment 6 Lucas Gass (lukeg) 2024-01-12 22:11:50 UTC
Backported to 23.05.x for upcoming 23.05.08