Closed shivan closed 10 months ago
I'm experciencing the same thing. The only workaround I found is to fill all the fields of the CSV file even the non mandatory ones. The error mentionned in the issue disappears but unfortunately another error happens next
Une erreur est survenue sur api/client-anr/1/rolf-risks : count(): Argument #1 ($value) must be of type Countable|array, null given (500)
I found the issue. It seems that during the import, the code is trying to link the measures to the Operational Risk. But since the CSV does not contain any measures, the access to the measure key fails.
In order to fix this, you can modify the ApiAnrRolfRisksController.php
file located here /var/lib/monarc/releases/MonarcAppFO-v2.12.7/vendor/monarc/frontoffice/src/Controller
and replace the create function by the one below.
It just checks if the measures key exists before trying to get the array length. Since its empty, the import works.
I will try to do a PR later today
public function create($data)
{
if (array_key_exists("measures",$data)){
if(count($data['measures'])>0)
$data['measures'] = $this->addAnrId($data['measures']);
}
return parent::create($data);
}
This fix is incomplete since it is still needed to fill all the fields of the CSV even the non-mandatory ones.
To be clear, to use the import feature you need to:
"code";"label";"description";"tags";"controls"
"CODE1";"MYLABEL";"MYDESCRIPTION";"RANDOMTAG";""
Initially was mentioned MONARC version 2.12.6 (as it was at the time of report), but based on the details we could see that it is 2.12.7. In any case the CSV import of Operational risks has an issue, we are going to fix it. Thank you for reporting.
Thank you for the prompt response and reaction!
Thank you for the report and your contribution. The patch is deployed on our production, my.monarc.lu
Describe the bug Exported data cannot be imported again. Even simple files cannot be imported.
To Reproduce Steps to reproduce the behavior:
Expected behavior Data is imported successfully
Screenshots n/a
Desktop (please complete the following information):
Additional context Same occurs with xlsx import. When really leaving label empty, you get an error before import.