Bug 37622

Summary: Error in ERM module when editing an agreement, a license, a package or a titles
Product: Koha Reporter: Hammat wele <hammat.wele>
Component: ERMAssignee: Hammat wele <hammat.wele>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: caroline.cyr-la-rose, jonathan.druart, jonathan.field, martin.renvoize, matt.blenkinsop, pedro.amorim, philippe.blouin, william.lavoie
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 37622: Error in erm module when editing an agreement, a license, a package or a titles
Bug 37622: Error in erm module when editing an agreement, a license, a package or a titles

Description Hammat wele 2024-08-12 21:23:13 UTC
Error in erm module when editing an agreement, a license, a package or a title

To reproduce

1- Enable the ERMModule system preference
    1- Go to Administration > System Preferences
    2- Search for ERMModule
    3- Change the value to "Enable"
    4- Click on "Save all e-resource management preferences"
    5- Return to the main screen
1- Create an agreement
    1- Go to e-resource management
    2- Click on "Agreements"
    3- Click on "New agreement"
    4- Fill out the form (mandatory fields)
        - Agreement name: Natural Medicines
        - Status: Active
    5- Click on "Submit"
2- Edit the agreement
    1- Click on "Agreements"
    2- Click on "Edit" to the right of the Natural Medicines agreement
    3- Click on "Submit"
        --> Something went wrong: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
We got the same error when editing a license, a package or a title
Comment 1 Hammat wele 2024-08-12 21:41:11 UTC
Created attachment 170248 [details] [review]
Bug 37622: Error in erm module when editing an agreement, a license, a package or a titles

To reproduce

1- Enable the ERMModule system preference
    1- Go to Administration > System Preferences
    2- Search for ERMModule
    3- Change the value to "Enable"
    4- Click on "Save all e-resource management preferences"
    5- Return to the main screen
1- Create an agreement
    1- Go to e-resource management
    2- Click on "Agreements"
    3- Click on "New agreement"
    4- Fill out the form (mandatory fields)
        - Agreement name: Natural Medicines
        - Status: Active
    5- Click on "Submit"
2- Edit the agreement
    1- Click on "Agreements"
    2- Click on "Edit" to the right of the Natural Medicines agreement
    3- Click on "Submit"
        --> Something went wrong: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
We got the same error when editing a license, a package or a title
Comment 2 Pedro Amorim 2024-08-13 08:32:04 UTC
I can't reproduce the error. Creating and editing an agreement works for me as expected, no errors. Running on latest main. Can you please revisit the test plan or verify how exactly to reproduce the error? Thanks.
Comment 3 Hammat wele 2024-08-13 14:46:16 UTC
(In reply to Pedro Amorim from comment #2)
> I can't reproduce the error. Creating and editing an agreement works for me
> as expected, no errors. Running on latest main. Can you please revisit the
> test plan or verify how exactly to reproduce the error? Thanks.

When I follow the previous steps, i can't edit a agreement and i got 

Something went wrong: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data    as error

And when i inspect the page before submitting the form i can see in the console the following error

PUT http://master-intranet/api/v1/erm/agreements/api/v1/erm/agreements/2/2    HTTP/1.1 404 Not Found
Comment 4 Pedro Amorim 2024-08-14 11:08:16 UTC
Still can't reproduce on current main branch.
Are you able to provide more information? What version is this happening on? Are you encountering this issue on a dev k-t-d environment or on a live environment?
Comment 5 William Lavoie 2025-01-14 19:17:49 UTC
I was able to reproduce the error on the main on a live environment by following the test plan. The patch worked also.
Comment 6 William Lavoie 2025-01-15 13:32:25 UTC
Created attachment 176567 [details] [review]
Bug 37622: Error in erm module when editing an agreement, a license, a package or a titles

To reproduce

1- Enable the ERMModule system preference
    1- Go to Administration > System Preferences
    2- Search for ERMModule
    3- Change the value to "Enable"
    4- Click on "Save all e-resource management preferences"
    5- Return to the main screen
1- Create an agreement
    1- Go to e-resource management
    2- Click on "Agreements"
    3- Click on "New agreement"
    4- Fill out the form (mandatory fields)
        - Agreement name: Natural Medicines
        - Status: Active
    5- Click on "Submit"
2- Edit the agreement
    1- Click on "Agreements"
    2- Click on "Edit" to the right of the Natural Medicines agreement
    3- Click on "Submit"
        --> Something went wrong: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
We got the same error when editing a license, a package or a title
Comment 7 William Lavoie 2025-01-15 13:32:41 UTC
Rebased
Comment 8 Jonathan Druart 2025-01-15 14:17:01 UTC
This patch removes the support of additional fields for agreements on edition.
Comment 9 Jonathan Druart 2025-01-15 14:18:40 UTC
And I don't get the error on main.

Please test on a sandbox/main and confirm you get the error there.