[Bug 36505] New: Cannot update patron attributes via PUT reuqst on Patrons endpoint
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Bug ID: 36505 Summary: Cannot update patron attributes via PUT reuqst on Patrons endpoint Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: nick@bywatersolutions.com CC: tomascohen@gmail.com According to our docs, you can include an array of patron attributes on a patrons PUT request: https://api.koha-community.org/Development.html#tag/patrons/operation/update... When testing I sent: {"category_id":"PT","library_id":"CPL","surname":"Ballard","extended_attributes":[{"extended_attribute_id":"1","type":"SHOW_BCODE","value":"0"}]} And I got an error: [2024/04/03 17:27:40] [ERROR] PUT /api/v1/patrons/21: unhandled exception (Koha::Exceptions::Object::PropertyNotFound)<<No property extended_attributes for Koha::Patron>> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Cannot update patron |Cannot update patron |attributes via PUT reuqst |attributes via PUT request |on Patrons endpoint |on Patrons endpoint -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff Summary|Cannot update patron |Allow updating patron |attributes via PUT request |attributes via PUT |on Patrons endpoint | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 164499 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164499&action=edit Bug 36505: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 164500 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164500&action=edit Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id This patch does what the title says. With it, you will be able to PUT on the already existing endpoint, but also pass: ```json [ { "type": "THE_TYPE", "value": "a" }, ... ] ``` Bonus: to ease testing I added `x-koha-embed: extended_attributes` support. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/patrons.t => FAIL: This is not implemented! 3. Apply this patch 4. Repeat 2 => SUCCESS: Exhaustive testes pass! 5. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com, | |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Michelle Spinney <mspinney@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mspinney@clamsnet.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 164527 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164527&action=edit Bug 36505: (follow-up) Consistent error codes in POST -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |blawlor@clamsnet.org Status|Needs Signoff |Patch doesn't apply --- Comment #4 from Brendan Lawlor <blawlor@clamsnet.org> --- When I try to apply this patch I get this error: Applying: Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id error: sha1 information is lacking or useless (Koha/REST/V1/Patrons.pm). error: could not build fake ancestor Patch failed at 0001 Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id Thanks for working on this! We need this to work for our eCard renewal vendor to update patron attibutes correctly. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Signed Off Depends on| |36495 --- Comment #5 from Tomás Cohen Arazi <tomascohen@gmail.com> --- This was missing a dependency. Hopefully those will be pushed pretty soon. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36495 [Bug 36495] Add resource_not_found() and resource_deleted() helpers -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #6 from Brendan Lawlor <blawlor@clamsnet.org> --- (In reply to Tomás Cohen Arazi from comment #5)
This was missing a dependency. Hopefully those will be pushed pretty soon.
Thanks Tomás. Is there a bug to watch for the dependency to be pushed. I would like to follow up and test this when I can. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #7 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Brendan Lawlor from comment #6)
(In reply to Tomás Cohen Arazi from comment #5)
This was missing a dependency. Hopefully those will be pushed pretty soon.
Thanks Tomás. Is there a bug to watch for the dependency to be pushed. I would like to follow up and test this when I can.
Hi, Brendan. If you are testing using KTD, when you try to do a: ```shell git fetch git checkout origin/master -b bug_36505 git bz apply 36505 ``` the last command should offer you the option to recursivelly apply the dependencies! If you feel like, give it a try. My only advise is: sometimes it is not smart enough and it offers you to apply an already applied bug. But that doesn't happen quite often. Thanks for your interest on this bug! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164499|0 |1 is obsolete| | --- Comment #8 from Brendan Lawlor <blawlor@clamsnet.org> --- Created attachment 164771 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164771&action=edit Bug 36505: Unit tests Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164500|0 |1 is obsolete| | --- Comment #9 from Brendan Lawlor <blawlor@clamsnet.org> --- Created attachment 164772 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164772&action=edit Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id This patch does what the title says. With it, you will be able to PUT on the already existing endpoint, but also pass: ```json [ { "type": "THE_TYPE", "value": "a" }, ... ] ``` Bonus: to ease testing I added `x-koha-embed: extended_attributes` support. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/patrons.t => FAIL: This is not implemented! 3. Apply this patch 4. Repeat 2 => SUCCESS: Exhaustive testes pass! 5. Sign off :-D Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164527|0 |1 is obsolete| | --- Comment #10 from Brendan Lawlor <blawlor@clamsnet.org> --- Created attachment 164773 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164773&action=edit Bug 36505: (follow-up) Consistent error codes in POST Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #11 from Brendan Lawlor <blawlor@clamsnet.org> --- Thanks Tomás! Testing notes: Apply dependencies and patch ```shell git fetch git checkout origin/master -b bug_36505 git bz apply 36505 ``` Enable system preference RESTOAuth2ClientCredentials Create a patron with edit borrowers permissions Get an API authentication token curl --location --request PUT 'http://localhost:8080/api/v1/patrons/21' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer MTcxMjg0OTAyOC00NTc2OTEtMC4yNTUwNzU4MzY0NjM2NS1SbVF0UzdROW1qTDE0b1ViVjJKYXhuSFFlblZLcjY=' \ --data '{ "category_id": "PT", "library_id": "CPL", "surname": "Ballard", "extended_attributes": [ { "extended_attribute_id": "1", "type": "SHOW_BCODE", "value": "1" } ] }' This returns 200 and updates the patron attribute! Run test: kohadev-koha@kohadevbox:koha(bug_36505)$ prove t/db_dependent/api/v1/patrons.t t/db_dependent/api/v1/patrons.t .. ok All tests successful. Files=1, Tests=7, 11 wallclock secs ( 0.03 usr 0.01 sys + 9.11 cusr 0.65 csys = 9.80 CPU) Result: PASS -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=30657 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164771|0 |1 is obsolete| | --- Comment #12 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 165409 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=165409&action=edit Bug 36505: Unit tests Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164772|0 |1 is obsolete| | --- Comment #13 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 165410 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=165410&action=edit Bug 36505: Add support for `extended_attributes` in PUT /patrons/:patron_id This patch does what the title says. With it, you will be able to PUT on the already existing endpoint, but also pass: ```json [ { "type": "THE_TYPE", "value": "a" }, ... ] ``` Bonus: to ease testing I added `x-koha-embed: extended_attributes` support. To test: 1. Apply the unit tests 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/patrons.t => FAIL: This is not implemented! 3. Apply this patch 4. Repeat 2 => SUCCESS: Exhaustive testes pass! 5. Sign off :-D Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164773|0 |1 is obsolete| | --- Comment #14 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 165411 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=165411&action=edit Bug 36505: (follow-up) Consistent error codes in POST Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact| |martin.renvoize@ptfs-europe | |.com Status|Signed Off |Passed QA --- Comment #15 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Fixed and working, thanks Tomas. Tests passing and present. Passing QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #16 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- This is just the tip of the iceberg, the dependency includes several "enh" bugs. Skipping for now (will be back later). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |24.05.00 released in| | Status|Passed QA |Pushed to main -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 --- Comment #17 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Pushed for 24.05! Well done everyone, thank you! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m Status|Pushed to main |Needs documenting --- Comment #18 from Fridolin Somers <fridolin.somers@biblibre.com> --- This is a big patch I prefer not to backport to 23.11.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|Needs documenting |RESOLVED CC| |caroline.cyr-la-rose@inlibr | |o.com --- Comment #19 from Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> --- API change, nothing to add/edit in the Koha manual. I assume API documentation is done automatically? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36505 Bug 36505 depends on bug 36495, which changed state. Bug 36495 Summary: Add render_resource_not_found() and render_resource_deleted() helpers https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36495 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org