Invalid File Path When Importing Targets Error

We recently upgraded from Sugar 8.0.2 to 9.0.2. We have started to notice a new error when importing targets. Whenever you change the field mapping during the import the screen turns white after clicking import targets. We checked our error logs and found the message below. Does anyone know of a permanent solution for this? In the mean time we are just fixing the import file headings to they map automatically when importing.

Sugar Version: Professional 9.0.2

Exception in Controller: Sugarcrm\Sugarcrm\Security\InputValidation\Exception\ViolationException: Invalid file path in /var/www/html/sugar/modules/Import/sources/ImportFile.php:103
Stack trace:
#0 /var/www/html/sugar/modules/Import/views/view.last.php(157): ImportFile->__construct('upload://import...', ',', '"', false, false)
#1 /var/www/html/sugar/modules/Import/views/view.last.php(114): ImportViewLast->getListViewTableFromFile('upload://import...', 'dup')
#2 /var/www/html/sugar/include/MVC/View/SugarView.php(153): ImportViewLast->display(Array)
#3 /var/www/html/sugar/include/MVC/Controller/SugarController.php(350): SugarView->process(Array)
#4 /var/www/html/sugar/include/MVC/Controller/SugarController.php(298): SugarController->processView()
#5 /var/www/html/sugar/include/MVC/SugarApplication.php(199): SugarController->execute()
#6 /var/www/html/sugar/index.php(27): SugarApplication->execute()
#7 {main}

Thanks,

Dan

Parents
  • Hi Dan,

    A white screen is typically indicative of a PHP error which typically logged at the web server level. The error you referenced appears to be a correlating error from Sugar's logs. A likely cause here may be that permissions were corrupted upon executing the upgrade, and the Sugar KB article, Required File System Permission on Linux, provides guidance on the recommended settings.

    If you still experience a white screen behavior after setting the recommended permissions, then please advise on what, if any, PHP error is logged for this event.

    Thanks!

  • Hi Chris Raffle,

    We checked and the permission looked good. This is the php error message:

    PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /var/www/html/xxxx/modules/Import/views/ImportListView.php on line 95.

    Line 95 in that file says this:

    $this->ss->assign('colCount', count($this->headerColumns));

    Any advice?

  • Hi Dan,

    This code is invoked to generate the Duplicate and Errors tabs on the import confirmation page. I tried a few tests on my own but I was unable to reproduce the issue. I tried the following:

    - Importing a CSV with a header row

    - Importing a CSV with no header row and all records successfully imported

    - Importing a CSV with no header row and some records reported as duplicate

    - Importing a CSV with no header row and some records reported as error

    Under each scenario, the confirmation page was displayed as expected and the Duplicate and Error tabs showed their information as expected. Please provide some more details about the file you typically try to import, and we may be able to identify the proper steps to reproduce the issue:

    1. Is file a CSV or is it delimited by some other means (e.g. tab)?
    2. Does the file contain a header row?
    3. If the file does not contain a header row, does step 3 of the import process properly identify that no header row was found above the data examples?

    Thanks!

  • Hey Chris Raffle,

    Here are some screen shots and the answers to your questions. I also realized the targets are imported correctly every time, we just don't see step 6 to add them to a target list.

    1. Microsoft Excel Comma Separated Values File

    2. This is happening whenever a file is imported without a header row or whenever we have to change the field mappings on step 4.

    3. Step 3 does say there is no header row.

    Thanks again for the help.

  • Thanks, Dan. I am still unable to reproduce with these additional details. Can you attach the sample CSV file you are used for your example above? I would like to compare some other file characteristics.

    Thanks!

  • Hi Chris Raffle,

    Sorry I didn't see your reply. I have attached the sample csv file below.

    When you import the file only the email address field will map perfectly. I then map the Contacts header to "Name" and I leave the Company head as "Do not map this field".

    Please let me know if you have any more questions.

    Thanks again for the help.

Reply
  • Hi Chris Raffle,

    Sorry I didn't see your reply. I have attached the sample csv file below.

    When you import the file only the email address field will map perfectly. I then map the Contacts header to "Name" and I leave the Company head as "Do not map this field".

    Please let me know if you have any more questions.

    Thanks again for the help.

Children
  • Hi Dan,

    Thank you for providing the sample file! I was unable to reproduce the error you receive using that same import file, and I tested on Sugar 9.0.2, 9.2.0, and 9.3.0. It's possible your import file properties are different than mine so I am including a screenshot of those properties from step 3 of the import process:

    If you have the same properties configured, then I recommend opening a case with Sugar Support to investigate this further.

  • HiChris Raffle,

    So I was able to get around the error by comparing the code in the modules\Import\sources\ImportFile.php in Sugar versions 9.0.2 and 8.0.2.

    In the 9.0.2 version there was additional code added on line 94:

    $uploadDir = UploadStream::getDir();
    $uploadPath = UploadStream::path($filename);
    if (null === $uploadPath) {
    return false;
    }
    $fileConstraint = new File(['baseDirs' => [realpath($uploadDir)]]);
    $violations = Validator::getService()->validate($uploadPath, $fileConstraint);

    if ($violations->count()) {
    throw new ViolationException('Invalid file path', $violations);

    By commenting this code out, the import process worked. This should help point me in the right direction as the ImportFile.php references where my file must be breaking in one of these 3 places:

    use Sugarcrm\Sugarcrm\Security\Validator\Validator;
    use Sugarcrm\Sugarcrm\Security\Validator\Constraints\File;
    use Sugarcrm\Sugarcrm\Security\InputValidation\Exception\ViolationException;

    Thanks,

    Dan