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

Unidentified index in SafeStorage.php:30 when reading a file #36

Closed
lourdrivera123 opened this issue Feb 21, 2017 · 14 comments
Closed

Unidentified index in SafeStorage.php:30 when reading a file #36

lourdrivera123 opened this issue Feb 21, 2017 · 14 comments

Comments

@lourdrivera123
Copy link

Hi, I am using Laravel and I updated my version to 1.0.13. The sftp adapter connects well, but when trying to read a file from the FTP, I encountered Unidentified index error.

[2017-02-21 23:08:56] local.ERROR: ErrorException: Undefined index: 0000000007f314c30000000000f2f7e7 in /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem/src/SafeStorage.php:30
Stack trace:
#0 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem/src/SafeStorage.php(30): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined index...', '/home/vagrant/c...', 30, Array)
#1 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php(250): League\Flysystem\SafeStorage->retrieveSafely('password')
#2 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem-sftp/src/SftpAdapter.php(246): League\Flysystem\Adapter\AbstractFtpAdapter->getPassword()
#3 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem-sftp/src/SftpAdapter.php(191): League\Flysystem\Sftp\SftpAdapter->getAuthentication()
#4 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem-sftp/src/SftpAdapter.php(172): League\Flysystem\Sftp\SftpAdapter->login()
#5 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php(575): League\Flysystem\Sftp\SftpAdapter->connect()
#6 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem-sftp/src/SftpAdapter.php(491): League\Flysystem\Adapter\AbstractFtpAdapter->getConnection()
#7 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem-sftp/src/SftpAdapter.php(483): League\Flysystem\Sftp\SftpAdapter->getMetadata('20.order/orders...')
#8 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem/src/Filesystem.php(56): League\Flysystem\Sftp\SftpAdapter->has('20.order/orders...')
#9 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem/src/Filesystem.php(384): League\Flysystem\Filesystem->has('20.order/orders...')
#10 /home/vagrant/code/kundan-v4-backend/vendor/league/flysystem/src/Filesystem.php(178): League\Flysystem\Filesystem->assertPresent('20.order/orders...')
#11 /home/vagrant/code/kundan-v4-backend/app/Listeners/EDI/SaveOrders.php(26): League\Flysystem\Filesystem->read('20.order/orders...')
#12 [internal function]: App\Listeners\EDI\SaveOrders->handle(Object(App\Events\EDI\FTPWasChecked))
#13 /home/vagrant/code/kundan-v4-backend/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(354): call_user_func_array(Array, Array)
#14 [internal function]: Illuminate\Events\Dispatcher->Illuminate\Events{closure}(Object(App\Events\EDI\FTPWasChecked))
#15 /home/vagrant/code/kundan-v4-backend/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(221): call_user_func_array(Object(Closure), Array)
#16 /home/vagrant/code/kundan-v4-backend/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(480): Illuminate\Events\Dispatcher->fire('App\Events\EDI\...')
#17 /home/vagrant/code/kundan-v4-backend/routes/console.php(56): event(Object(App\Events\EDI\FTPWasChecked))
#18 [internal function]: Illuminate\Foundation\Console\ClosureCommand->{closure}()
#19 /home/vagrant/code/kundan-v4-backend/vendor/laravel/framework/src/Illuminate/Container/Container.php(508): call_user_func_array(Object(Closure), Array)
#20 /home/vagrant/code/kundan-v4-backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClosureCommand.php(55): Illuminate\Container\Container->call(Object(Closure), Array)
#21 /home/vagrant/code/kundan-v4-backend/vendor/symfony/console/Command/Command.php(261): Illuminate\Foundation\Console\ClosureCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /home/vagrant/code/kundan-v4-backend/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /home/vagrant/code/kundan-v4-backend/vendor/symfony/console/Application.php(817): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /home/vagrant/code/kundan-v4-backend/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Foundation\Console\ClosureCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /home/vagrant/code/kundan-v4-backend/vendor/symfony/console/Application.php(116): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /home/vagrant/code/kundan-v4-backend/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /home/vagrant/code/kundan-v4-backend/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 {main}

@lourdrivera123
Copy link
Author

Any help ?

@frankdejonge
Copy link
Member

@lourdrivera123 within 15 hours you've opened this issue AND send an email to my personal account. If you think that's the way you're getting your issue fixed you're sorely mistaken.

@lourdrivera123
Copy link
Author

lourdrivera123 commented Feb 22, 2017

@frankdejonge Sorry about that, just had the thought that you or others also experienced the same issue.

@lourdrivera123
Copy link
Author

Tried googling around, found this guy having the same issue as mine:
http://stackoverflow.com/questions/42025800/laravel-flysystem-file-put-error-when-using-queues

@Stelian
Copy link

Stelian commented Feb 22, 2017

@frankdejonge I could have a look at it tomorrow morning and come up with a PR. This is an open source project after all.

@lourdrivera123
Copy link
Author

Thank you so much @Stelian

@Stelian
Copy link

Stelian commented Feb 22, 2017

@lourdrivera123 what version of Laravel are you experiencing the issue with? Can you also add a gist with the actual code?

@Stelian
Copy link

Stelian commented Feb 23, 2017

@lourdrivera123 looked into it and it does not seem to be an issue with the SFTP package, tested it and there is no way to reproduce that unless you do not properly construct the class or overwrite the hash somewhere.

I also do not see in your call stack where you actually call the __construct of the FTP Adapter, that seems to be missing. Can you give me a bit more context here?

@frankdejonge
Copy link
Member

Closed due to lack of response.

@frankdejonge
Copy link
Member

If the problem still persists please comment and I'll reopen.

@nextafter-dan
Copy link

I just ran into this same error. I was using Lumen (basically same as Laravel), and pushed a Job into a Amazon SQS queue. In my case, within the job I was just trying to listContents(). For my project I just reverted to a version before SafeStorage.php was added, I believe 1.0.27.

If I had a guess the key is not getting set initially when setting a password, could this be a difference between plain text vs private key?

@ivannovak
Copy link

I've now run into the same error. I've done the same as @nextafter-dan and pushed a job into the queue. This is NOT a problem when using the queue synchronously (e.g. sync). This becomes a problem as soon as it's pushed to an async queue. I've tried with AWS SQS (sqs) and Beanstalk (beanstalkd).

@ivannovak
Copy link

I was able to get it working. Seems we can't send the filesystem through the queue nor can we instantiate the file system in the constructor. It seems like SafeStorage forces the filesystem instantiation and use to be within the same method call. Huge win for getting it working, but super confusing problem.

@twistor twistor reopened this Jun 21, 2017
@twistor
Copy link

twistor commented Jun 21, 2017

This issue should be in Flysystem proper, but I will document it here.

League\Flysystem\SafeStorage uses spl_object_hash() to store values. The point is so keys do not leak during exceptions.

When unserializing, the object hash will be different, hence the missing keys.

I would argue, and this should be documented, that this is the correct behavior. Preventing serialization of credentials is a good thing.

We should probably implement __serialize() and throw a helpful exception. This would also prevent actually serializing they sensitive info. I think at the moment, the key info is still serialized, just not accessible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants