Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Label required" on import risks even when label filled #484

Closed
shivan opened this issue May 5, 2023 · 6 comments
Closed

"Label required" on import risks even when label filled #484

shivan opened this issue May 5, 2023 · 6 comments
Assignees
Labels

Comments

@shivan
Copy link

shivan commented May 5, 2023

Describe the bug
Exported data cannot be imported again. Even simple files cannot be imported.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Knowledge Base
  2. Click on Operational Risks
  3. Click on +
  4. click on "import from file"
  5. import the following file
"code";"Label";"description";"tags"
"test";"asdf";"test";
  1. Now you get an error "Label required"

Expected behavior
Data is imported successfully

Screenshots
n/a

Desktop (please complete the following information):

Questions Answers
Type of issue Bug
OS version (server) Ubuntu
OS version (client) Win10
PHP version ova image
MONARC version / git hash 2.12.6
Browser Chrome

Additional context
Same occurs with xlsx import.
When really leaving label empty, you get an error before import.

@acherifi
Copy link

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)

@acherifi
Copy link

acherifi commented Nov 14, 2023

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:

  1. Fill all the fields of the CSV files with the following format (only the controls can be left empty)
"code";"label";"description";"tags";"controls"
"CODE1";"MYLABEL";"MYDESCRIPTION";"RANDOMTAG";""
  1. Replace the create function by the one above

@ruslanbaidan
Copy link
Contributor

ruslanbaidan commented Nov 14, 2023

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.

@ruslanbaidan
Copy link
Contributor

The issue is due to count function param change since php v8.0.
There is a patch with a fix for this.
It is going to be deployed to our production today.

@ruslanbaidan ruslanbaidan self-assigned this Nov 14, 2023
@ruslanbaidan ruslanbaidan added this to To do in MONARC Development Overview via automation Nov 14, 2023
@ruslanbaidan ruslanbaidan moved this from To do to Done (deployed on prod) in MONARC Development Overview Nov 14, 2023
@acherifi
Copy link

Thank you for the prompt response and reaction!

@ruslanbaidan
Copy link
Contributor

Thank you for the report and your contribution.
The patch is deployed on our production, my.monarc.lu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
MONARC Development Overview
  
Done (deployed on prod)
Development

No branches or pull requests

3 participants