[Bug 44067] New: Unable to Save Agreements with related records with notes field
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Bug ID: 44067 Summary: Unable to Save Agreements with related records with notes field Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: blocker Priority: P5 - low Component: ERM Assignee: koha-bugs@lists.koha-community.org Reporter: michaela.sieber@kit.edu QA Contact: testopia@bugs.koha-community.org CC: jonathan.druart@gmail.com, jonathan.field@openfifth.co.uk, martin.renvoize@openfifth.co.uk, matt.blenkinsop@openfifth.co.uk, pedro.amorim@openfifth.co.uk Target Milestone: --- # Description When linking an existing agreement to another agreement and entering information in the **Notes** field, saving the agreement may fail with the following error: ```json { "message": "Properties not allowed: _strings.", "path": "/body/agreement_relationships/0" } ``` The error indicates that the API rejects an unexpected property named `_strings` within the first object of the `agreement_relationships` array. ## Observed Payload The submitted payload contains the following structure: ```json { "agreement_relationships": [ { "_strings": {}, "agreement_id": 2, "notes": "", "related_agreement_id": 1, "relationship": "supersedes" } ] } ``` The `_strings` property appears to be an unexpected frontend-generated property that is included in the serialized API request. The API schema does not allow `_strings` within an `agreement_relationships` record. ## Steps to Reproduce 1. Create a new agreement (Agreement A1). 2. Create a second agreement (Agreement A2). 3. Navigate back to Agreement A1 and open it in Edit mode. 4. Link Agreement A2 to Agreement A1. 5. Enter some text in the **Notes** field of the relationship. 6. Save the agreement. **Note:** If the issue does not occur immediately, repeat the steps several times and try linking multiple agreement records with notes. ## Expected Result The agreement should be saved successfully, including the relationship and its associated notes. ## Actual Result Saving the agreement fails with the following API validation error: `Properties not allowed: _strings.` -- 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=44067 Michaela Sieber <michaela.sieber@kit.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clemens.tubach@kit.edu, | |katrin.fischer@bsz-bw.de -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 --- Comment #1 from Clemens Tubach <clemens.tubach@kit.edu> --- The problem also occurs when attaching documents: XHR PUT https://staff-main.koha-sandboxes.org/api/v1/erm/agreements/4 [HTTP/1.1 400 Bad Request 57ms] Payload ======= agreement_licenses [] agreement_relationships [] closure_reason null description "" documents (1)[…] 0 {…} _strings {} agreement_id 4 document_id 1 file_description null file_name "Test.pdf" license_id null notes null physical_location null uri null extended_attributes [] is_perpetual false license_info "" name "test with document" periods [] renewal_priority "" status "active" user_roles [] vendor_id null Answer ====== errors [ {…} ] 0 { message: "Properties not allowed: _strings.", path: "/body/documents/0" } message "Properties not allowed: _strings." path "/body/documents/0" status 400 ## Steps to Reproduce 1. Create a new agreement with a document 2. Save the agreement 3. Open it in Edit mode 4. Save the agreement **Note:** If the issue does not occur immediately, repeat the steps 3 and 4 several times -- 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=44067 Michaela Sieber <michaela.sieber@kit.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |regression, | |rel_26_05_candidate Status|NEW |CONFIRMED -- 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=44067 Sam Young <sam.young@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |sam.young@bywatersolutions. |ity.org |com CC| |sam.young@bywatersolutions. | |com -- 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=44067 Sam Young <sam.young@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|CONFIRMED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 --- Comment #2 from Sam Young <sam.young@bywatersolutions.com> --- Created attachment 211494 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211494&action=edit Bug 44067: Don't leak the strings flag into sibling embeds in to_api Koha::Object::to_api sets $params->{strings} inside the embed loop on the shared $params hashref. Once an embed requesting +strings is processed (e.g. periods+strings on ERM agreements), every embed iterated after it also gets a _strings attribute. Hash iteration order is random per process, so this happens intermittently depending on the Plack worker. The ERM agreement form sends the fetched related records back on save, so the stray _strings on user_roles, agreement_licenses, agreement_relationships or documents is rejected by the API with "Properties not allowed: _strings." This patch gives each embed its own copy of $params so the strings flag only applies to the embed that requested it. Test plan: 1. Create an ERM agreement with a user, a license, a related agreement and/or a document 2. Edit the agreement and click Save. Repeat several times => FAIL: "Something went wrong: Error: Properties not allowed: _strings." on some attempts 3. Apply this patch, restart_all 4. Repeat 2 => SUCCESS: The agreement saves every time -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 John Vinke <jvinke@austinseminary.edu> 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=44067 John Vinke <jvinke@austinseminary.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211494|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 --- Comment #3 from John Vinke <jvinke@austinseminary.edu> --- Created attachment 211519 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211519&action=edit Bug 44067: Don't leak the strings flag into sibling embeds in to_api Koha::Object::to_api sets $params->{strings} inside the embed loop on the shared $params hashref. Once an embed requesting +strings is processed (e.g. periods+strings on ERM agreements), every embed iterated after it also gets a _strings attribute. Hash iteration order is random per process, so this happens intermittently depending on the Plack worker. The ERM agreement form sends the fetched related records back on save, so the stray _strings on user_roles, agreement_licenses, agreement_relationships or documents is rejected by the API with "Properties not allowed: _strings." This patch gives each embed its own copy of $params so the strings flag only applies to the embed that requested it. Test plan: 1. Create an ERM agreement with a user, a license, a related agreement and/or a document 2. Edit the agreement and click Save. Repeat several times => FAIL: "Something went wrong: Error: Properties not allowed: _strings." on some attempts 3. Apply this patch, restart_all 4. Repeat 2 => SUCCESS: The agreement saves every time Signed-off-by: John Vinke <jvinke@austinseminary.edu> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |martin.renvoize@openfifth.c |y.org |o.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211519|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 --- Comment #4 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211538 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211538&action=edit Bug 44067: Don't leak the strings flag into sibling embeds in to_api Koha::Object::to_api sets $params->{strings} inside the embed loop on the shared $params hashref. Once an embed requesting +strings is processed (e.g. periods+strings on ERM agreements), every embed iterated after it also gets a _strings attribute. Hash iteration order is random per process, so this happens intermittently depending on the Plack worker. The ERM agreement form sends the fetched related records back on save, so the stray _strings on user_roles, agreement_licenses, agreement_relationships or documents is rejected by the API with "Properties not allowed: _strings." This patch gives each embed its own copy of $params so the strings flag only applies to the embed that requested it. Test plan: 1. Create an ERM agreement with a user, a license, a related agreement and/or a document 2. Edit the agreement and click Save. Repeat several times => FAIL: "Something went wrong: Error: Properties not allowed: _strings." on some attempts 3. Apply this patch, restart_all 4. Repeat 2 => SUCCESS: The agreement saves every time Signed-off-by: John Vinke <jvinke@austinseminary.edu> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Michaela Sieber <michaela.sieber@kit.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to main Version(s)| |26.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 --- Comment #5 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Thanks everyone! Pushed to main for 26.11! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 --- Comment #6 from Michaela Sieber <michaela.sieber@kit.edu> --- Thank you! Could this please be backported to 26.05.06 ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to main |Pushed to stable Version(s)|26.11.00 |26.11.00,26.05.06 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 --- Comment #7 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Nice work everyone! Pushed to 26.05.x for the upcoming 26.05.06 release. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rel_26_05_candidate | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44067 Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |baptiste.wojtkowski@biblibr | |e.com Version(s)|26.11.00,26.05.06 |26.11.00,26.05.06,25.11.11 released in| | Status|Pushed to stable |Pushed to oldstable --- Comment #8 from Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski@biblibre.com> --- Pushed into 25.11.x for 25.11.11 nice work everyone -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org