Jump to content


Download Zip No Longer Works (InvalidArgumentException)


  • Please log in to reply
12 replies to this topic

#1 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 16 December 2016 - 06:24 PM

Hello,
I recently discovered that the Download Zip button no longer works on our Swarm installation. Everything else seems to be fine. I just upgraded to 2016.3 today to see if that would fix the problem, but, it didn't.

On the Swarm page I get, "Error: Internal Server error". In the swarm log I get the following

2016-12-16T10:20:43-08:00 CRIT (2): exception 'InvalidArgumentException' with message 'Each view entry must contain two paths, no more, no less.' in /opt/perforce/swarm/library/P4/Spec/Client.php:498
Stack trace:
#0 /opt/perforce/swarm/module/Files/src/Files/Archiver.php(557): P4\Spec\Client->setView(Array)
#1 /opt/perforce/swarm/module/Files/src/Files/Archiver.php(119): Files\Archiver->grabArchiveClient(Object(P4\Connection\Extension))
#2 /opt/perforce/swarm/module/Files/src/Files/Controller/IndexController.php(337): Files\Archiver->getFilesInfo('//ParadePy/...', Object(P4\Connection\Extension))
#3 /opt/perforce/swarm/library/Zend/Mvc/Controller/AbstractActionController.php(83): Files\Controller\IndexController->archiveAction()
#4 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#5 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#6 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#7 /opt/perforce/swarm/library/Zend/Mvc/Controller/AbstractController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#8 /opt/perforce/swarm/library/Zend/Mvc/DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#9 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#10 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#11 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#12 /opt/perforce/swarm/library/Zend/Mvc/Application.php(309): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#13 /opt/perforce/swarm/public/index.php(61): Zend\Mvc\Application->run()
#14 {main}

I don't understand how Swarm users p4 client specs so I'm not sure what to check next.

#2 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 09 January 2017 - 10:46 PM

Wow, this form is really low traffic. I didn't check the frequency of new posts before asking my question. For those that may have a similar problem I haven't found the solution yet. I'll update this thread if I do.

#3 Ewan Edwards

Ewan Edwards

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 31 January 2017 - 05:24 PM

That looks like an issue with the workspace that Swarm is using, and Swarm should be able to handle that a bit more gracefully.

I'd suggest contacting Perforce support so that these details can be raised with the Swarm developers.

#4 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 31 January 2017 - 06:12 PM

Thanks for the suggestion. There is an error about the client view. However, I don't see anything wrong with the view paths in the client. For example, there are no spaces in any of the paths. Also, Swarm regenerates the client every time I attempt a download from the swarm web page.

2017-01-31T10:07:41-08:00 DEBUG (7): P4 (000000004a435e1100000000bbf15be8) start command: client -o swarm-29bea291-2fca-d2f3-cb29-f231285cfb18
2017-01-31T10:07:41-08:00 CRIT (2): exception 'InvalidArgumentException' with message 'Each view entry must contain two paths, no more, no less.' in /opt/perforce/swarm/library/P4/Spec/Client.php:498
Stack trace:
#0 /opt/perforce/swarm/module/Files/src/Files/Archiver.php(557): P4\Spec\Client->setView(Array)
#1 /opt/perforce/swarm/module/Files/src/Files/Archiver.php(119): Files\Archiver->grabArchiveClient(Object(P4\Connection\Extension))
#2 /opt/perforce/swarm/module/Files/src/Files/Controller/IndexController.php(337): Files\Archiver->getFilesInfo('//webapps/Eric/...', Object(P4\Connection\Extension))
#3 /opt/perforce/swarm/library/Zend/Mvc/Controller/AbstractActionController.php(83): Files\Controller\IndexController->archiveAction()
#4 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#5 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#6 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#7 /opt/perforce/swarm/library/Zend/Mvc/Controller/AbstractController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#8 /opt/perforce/swarm/library/Zend/Mvc/DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#9 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#10 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#11 /opt/perforce/swarm/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#12 /opt/perforce/swarm/library/Zend/Mvc/Application.php(309): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#13 /opt/perforce/swarm/public/index.php(61): Zend\Mvc\Application->run()
#14 {main}


#5 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 31 January 2017 - 06:20 PM

Digging a little deeper I updated the Swarm PHP code to include the View line that is is throwing an error on and the count. It seems like it is having a problem with spaces in the view path.

2017-01-31T10:17:58-08:00 CRIT (2): exception 'InvalidArgumentException' with message 'Each view entry must contain two paths, no more, no less.""//apps/CYSC/CDS_Mgmt/CDS Parade Memo Management/..."" ""//swarm-29bea291-2fca-d2f3-cb29-f231285cfb18/apps/CYSC/CDS_Mgmt/CDS Parade Memo Management/..."" Count = 8' in /opt/perforce/swarm/library/P4/Spec/Client.php:498

			$validate = str_getcsv($entry, ' ');
			if (count($validate) != 2 || trim($validate[0]) === '' || trim($validate[1]) === '') {
				throw new \InvalidArgumentException(
					"Each view entry must contain two paths, no more, no less." . $entry . " Count = " . count($validate)
				);
			}


#6 P4Karl

P4Karl

    Advanced Member

  • Administrators
  • 55 posts

Posted 02 February 2017 - 11:02 AM

Hi Simon,

Thanks for doing the digging.

I'm using a Linux P4D with 2016.1 and 2016.3 and cannot reproduce this however I'll raise a problem report for it. To help me please answer the following questions:
1 - Is this a Windows P4D server?
2 - What is the server version?
3 - Was this a streams depot?
4 - Do you also have paths with spaces in your protections table?

Note: You may find that clearing the Swarm cache fixes the issue.
- Stop Apache (at a quiet time on the system)
- Delete/move/rename '/opt/perforce/swarm/data/cache' (may be in a different location of you installed from tarball).
- Start Apache

Regards,

Karl

#7 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 02 February 2017 - 04:35 PM

Hello Karl,

Spaces in the protections table are the problem!

I tried cleaning the cache first, but that didn't help. Then as I got to your question #4 I check our protections table and we do have spaces. In fact the path that is reported in the error is exactly the same as the one in the protections table. As an experiment I removed these paths from the protections table and the zip download worked.

The path in the protections table is enclosed by double quotes. Do you know how to fix this issue?

With regard to your other questions we are running.
* P4D/LINUX26X86_64/2015.1/1171507
* Swarm is running on the same server as P4D. Our swarm version is: SWARM/2016.3/1472982 (2016/12/14)
* The path that is causing the error is not a stream depot.
* Yes our protections table has spaces in some paths.
        write user * * "-//apps/CYSC/CDS_Mgmt/CDS Parade Memo Management/..."
        read user * * "//apps/CYSC/CDS_Mgmt/CDS Parade Memo Management/..."

#8 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 06 February 2017 - 07:04 PM

Looking at the output more I see that the depot paths are double quoted twice. For example,
""//apps/CYSC/CDS_Mgmt/CDS Parade Memo Management/...""

This is happening because the string is already double quoted in the protections spec and then the code below applies another set of double quotes. If the code is going to use double quote as the enclosure character it should be escaping any existing instances of that character in the string. Since it doesn't escape the existing " characters the string ends up having "" at the start and "" at the end.

/opt/perforce/swarm/library/P4/Spec/Client.php setView function.
	 // The View array contains either:
	 // - Child arrays keyed on depot/client which we glue together
	 // - Raw strings which we simply leave as is
	 // The below foreach run will normalize the whole thing for storage
	 $parsedView = array();
	 foreach ($view as $entry) {
		 if (is_array($entry) &&
			 isset($entry['depot'], $entry['client']) &&
			 is_string($entry['depot']) &&
			 is_string($entry['client'])) {
			 $entry = '"'. $entry['depot'] .'" "'. $entry['client'] .'"';
}

This causes a problem later in the code when, str_getcsv($entry, ' '), is used to split the view into a depot path and a client path. The reason it is a problem is that the default enclosure character for, str_getcsv, is, ", therefore when str_getcsv() sees the, "", it sees it as a null string (nothing is between the quotes) and moves on rather than enclosing the string with spaces thus preventing those spaces from becoming split points.

To work around the problem I remove the extra double quotes from the $entry assignment.

OLD: $entry = '"'. $entry['depot'] .'" "'. $entry['client'] .'"';
NEW: $entry = $entry['depot'] .' '. $entry['client'];

This seems to work, although, I don't know if there are other cases where a string with spaces is feed in to entry that is not already double quoted. However, it seems to me that all view entries passed in to setView should already be double quoted and removing the extra double quotes is the right fix.

Eric

#9 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 22 May 2017 - 11:58 PM

This bug still exists in Swarm 2017.1. The good news is that the work around still works.

#10 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 22 January 2018 - 03:29 AM

Same issue in SWARM/2017.4/1596853. Work around still works.

#11 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 09 May 2018 - 02:55 PM

Same issue with SWARM/2018.1/1650837 (2018/04/20). The work around still works. It is surprising that other's are not running into this issue. It makes me think that double quoting of the $entry value is not the root cause.

#12 P4Dale

P4Dale

    Member

  • Staff
  • 27 posts

Posted 09 May 2018 - 03:34 PM

Hello Simon,

If you haven't done so please do open a support ticket about this. Then someone from the support team can log a job for this to be investigated and hopefully fix.

Please ensure you provide the below information:
1. p4 -ztag info
2. Swarm version
3. Example path that doesn't work
4. The error you are getting for this path with logging at level 7

With that information it would be a good start for support or developers to get a in house reproduction.

Regards,

Dale.

#13 simonswartz

simonswartz

    Member

  • Members
  • PipPip
  • 15 posts

Posted 09 May 2018 - 06:20 PM

Information sent!


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users