driver-telegram icon indicating copy to clipboard operation
driver-telegram copied to clipboard

Array to string conversion error on Laravel 5.6

Open malfianrasyidin opened this issue 7 years ago • 7 comments

Array to string conversion {"exception":"[object] (ErrorException(code: 0): Array to string conversion at /PROJECT-ROOT/vendor/botman/driver-telegram/src/TelegramDriver.php:138)

Don't know much what's wrong with this error, do you have any ideas to solve this error out? Thank you so much!

malfianrasyidin avatar Nov 02 '18 22:11 malfianrasyidin

Can you show us what code you wrote, just showing the error doesn't help enough.

christophrumpel avatar Nov 05 '18 06:11 christophrumpel

Actually, I don't know exactly what went wrong. It happened when I add this package https://packagist.org/packages/yajra/laravel-datatables-oracle to my project. Seems really odd. Which code should I provide? Thanks!

malfianrasyidin avatar Nov 10 '18 09:11 malfianrasyidin

Hmm what happens when you remove this package? Is it then working again? If not, then for us, it would be good to know what you did when you get this error. Did you write something to the bot? What is the code that you wrote or have you tested the BotMan Studio examples?

christophrumpel avatar Nov 24 '18 18:11 christophrumpel

the problem is in concept of loading bot logic from route file because botman-resolving will be triggered for each application request even if it is absolutely unnecessary I moved botman logic from route file to Controller handle method BotManController@handle. It solve problem globally, not only for yajra/laravel-datatables-oracle

Do not forget to add your webhook path to $except array in VerifyCsrfToken Middleware

AlekseiiShevchuk avatar Dec 10 '18 13:12 AlekseiiShevchuk

I having the same problem with the implementation of datatable with Botman

yog369 avatar Nov 08 '20 17:11 yog369

I got same issue with Botman v.2.6.1, telegram driver v1.6.2 and Laravel 5.8. Not sure why and I do not know how to reproduce it, but sometimes, $value in closure is an array. that is why line 154.

return $key.'='.$value;

throws exception. Still investigating. I will update when I get more information. I do not use datatable by the way as other mentioned, so I do not think this is related to datatable.

[2022-05-04 04:23:50] production.ERROR: Array to string conversion {"exception":"[object] (ErrorException(code: 0): Array to string conversion at /home/sinbot/vendor/botman/driver-telegram/src/TelegramDriver.php:154)
[stacktrace]
#0 /home/sinbot/vendor/botman/driver-telegram/src/TelegramDriver.php(154): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 [internal function]: BotMan\\Drivers\\Telegram\\TelegramDriver->BotMan\\Drivers\\Telegram\\{closure}()
#2 /home/sinbot/vendor/laravel/framework/src/Illuminate/Support/Collection.php(1120): array_map()
#3 /home/sinbot/vendor/botman/driver-telegram/src/TelegramDriver.php(155): Illuminate\\Support\\Collection->map()
#4 /home/sinbot/vendor/botman/driver-telegram/src/TelegramDriver.php(123): BotMan\\Drivers\\Telegram\\TelegramDriver->isValidLoginRequest()
#5 /home/sinbot/vendor/botman/botman/src/Drivers/DriverManager.php(174): BotMan\\Drivers\\Telegram\\TelegramDriver->hasMatchingEvent()
#6 /home/sinbot/vendor/botman/botman/src/BotManFactory.php(68): BotMan\\BotMan\\Drivers\\DriverManager->getMatchingDriver()
#7 /home/sinbot/vendor/botman/botman/src/BotManServiceProvider.php(22): BotMan\\BotMan\\BotManFactory::create()
#8 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/Container.php(785): BotMan\\BotMan\\BotManServiceProvider->BotMan\\BotMan\\{closure}()
#9 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\\Container\\Container->build()
#10 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\\Container\\Container->resolve()
#11 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(767): Illuminate\\Container\\Container->make()
#12 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(121): Illuminate\\Foundation\\Application->make()
#13 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(733): app()
#14 /home/sinbot/routes/botman.php(5): resolve()
#15 /home/sinbot/app/Providers/RouteServiceProvider.php(40): require('/home/sinbot/ap...')
#16 /home/sinbot/app/Providers/RouteServiceProvider.php(30): App\\Providers\\RouteServiceProvider->mapBotManCommands()
#17 [internal function]: App\\Providers\\RouteServiceProvider->map()
#18 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array()
#19 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#20 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod()
#21 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\\Container\\BoundMethod::call()
#22 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(87): Illuminate\\Container\\Container->call()
#23 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(36): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->loadRoutes()
#24 [internal function]: Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->boot()
#25 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array()
#26 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#27 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod()
#28 /home/sinbot/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\\Container\\BoundMethod::call()
#29 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(827): Illuminate\\Container\\Container->call()
#30 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(810): Illuminate\\Foundation\\Application->bootProvider()
#31 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}()
#32 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(811): array_walk()
#33 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#34 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(210): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap()
#35 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\\Foundation\\Application->bootstrapWith()
#36 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#37 /home/sinbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#38 /home/sinbot/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle()
#39 {main}
"}

zamronypj avatar May 04 '22 16:05 zamronypj

The problem is still there and is thrown randomly on the line 154. I can see it in logs.

https://github.com/botman/driver-telegram/blob/b681bf94a8e1537c385a34131e8de8075c3866c8/src/TelegramDriver.php#L154

I can reliably reproduce it when I'm trying to delete an object from the DB via Laravel Nova (v2). I have no idea why Telegram driver is even called in that case. Looks like isValidLoginRequest() is called by mistake.

From Nova request I can see that $this->queryParameters is equal to {"search":"","filters":"W10=","trashed":"","resources":["6157"]} and as you can see the last parameter is an array.

I believe @AlekseiiShevchuk is right and the Telegram Driver is called all the time even when it's not needed because it runs from routes. @AlekseiiShevchuk could you, please, share some code?

Looks like getting rid of routes/botman.php makes tests impossible.

chimit avatar Jul 05 '23 15:07 chimit