[GH-ISSUE #636] Postgres error while syncing: invalid byte sequence for encoding "UTF8" #455

Closed
opened 2026-02-26 02:33:15 +03:00 by kerem · 2 comments
Owner

Originally created by @svalo on GitHub (Aug 18, 2017).
Original GitHub issue: https://github.com/koel/koel/issues/636

Hello, I'm encounering some issues while using postgres with koel, tryied with mariadb and did not have problems.
I'm not sure whether this is an issue with koel itself or not.
OS: archlinux
Postgres version:9.6.3
MariaDB version:10.1.26-MariaDB
Php version: 7.1.8
Koel is configured using php-fpm + nginx

Issue is:
While scanning koel excepts and dies with errors like

 [Illuminate\Database\QueryException (22021)]                                                                                                                           
 SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0xff (SQL: select * from "albums" where ("artist_id" = 52 and "nam  
 e" = ��nUnkwo) limit 1)                                                                                                                                                
                                                                                                                                                                        

Exception trace:
() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:647
Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607
Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326
Illuminate\Database\Connection->select() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1711
Illuminate\Database\Query\Builder->runSelect() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1696
Illuminate\Database\Query\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:462
Illuminate\Database\Eloquent\Builder->getModels() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:446
Illuminate\Database\Eloquent\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:71
Illuminate\Database\Eloquent\Builder->first() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:354
Illuminate\Database\Eloquent\Builder->firstOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329
Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341
Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/Album.php:65
App\Models\Album::get() at /srv/http/koel/app/Models/File.php:248
App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84
App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74
App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54
App\Console\Commands\SyncMedia->handle() at n/a:n/a
call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531
Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182
Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265
Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167
Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826
Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189
Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120
Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123
Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35

                                                                                                          
 [PDOException (22021)]                                                                                   
 SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0xff  
                                                                                                          

Exception trace:
() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:323
PDOStatement->execute() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:323
Illuminate\Database\Connection->Illuminate\Database\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:640
Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607
Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326
Illuminate\Database\Connection->select() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1711
Illuminate\Database\Query\Builder->runSelect() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1696
Illuminate\Database\Query\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:462
Illuminate\Database\Eloquent\Builder->getModels() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:446
Illuminate\Database\Eloquent\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:71
Illuminate\Database\Eloquent\Builder->first() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:354
Illuminate\Database\Eloquent\Builder->firstOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329
Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341
Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/Album.php:65
App\Models\Album::get() at /srv/http/koel/app/Models/File.php:248
App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84
App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74
App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54
App\Console\Commands\SyncMedia->handle() at n/a:n/a
call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531
Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182
Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265
Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167
Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826
Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189
Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120
Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123
Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35

and

[Illuminate\Database\QueryException (22021)]                                                                                                                           
  SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0xfe (SQL: insert into "songs" ("id", "title", "length", "track",   
  "lyrics", "path", "mtime", "album_id", "contributing_artist_id", "updated_at", "created_at") values (ce24f5dd9c07c0868917cde2efa3da44, Any Colour You Like, 205.68812  
  5, 7, ��, <redacted>/Pink Floyd/Dark Side Of The Moon/07 Any Colour You Like.mp3, 1250523022, 318, 157, 2017-08-18 08:26:55, 2017-08-18 08:26:55))              
                                                                                                                                                                         

Exception trace:
 () at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:647
 Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607
 Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:450
 Illuminate\Database\Connection->statement() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:404
 Illuminate\Database\Connection->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2116
 Illuminate\Database\Query\Builder->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1242
 Illuminate\Database\Eloquent\Builder->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:650
 Illuminate\Database\Eloquent\Model->performInsert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:508
 Illuminate\Database\Eloquent\Model->save() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:377
 Illuminate\Database\Eloquent\Builder->Illuminate\Database\Eloquent\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/helpers.php:878
 tap() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:378
 Illuminate\Database\Eloquent\Builder->updateOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329
 Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341
 Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/File.php:277
 App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84
 App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
 Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74
 App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54
 App\Console\Commands\SyncMedia->handle() at n/a:n/a
 call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
 Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
 Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531
 Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182
 Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265
 Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167
 Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826
 Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120
 Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123
 Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35

                                                                                                           
  [PDOException (22021)]                                                                                   
  SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0xfe  
                                                                                                           

Exception trace:
 () at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:449
 PDOStatement->execute() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:449
 Illuminate\Database\Connection->Illuminate\Database\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:640
 Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607
 Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:450
 Illuminate\Database\Connection->statement() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:404
 Illuminate\Database\Connection->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2116
 Illuminate\Database\Query\Builder->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1242
 Illuminate\Database\Eloquent\Builder->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:650
 Illuminate\Database\Eloquent\Model->performInsert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:508
 Illuminate\Database\Eloquent\Model->save() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:377
 Illuminate\Database\Eloquent\Builder->Illuminate\Database\Eloquent\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/helpers.php:878
 tap() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:378
 Illuminate\Database\Eloquent\Builder->updateOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329
 Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341
 Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/File.php:277
 App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84
 App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221
 Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74
 App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54
 App\Console\Commands\SyncMedia->handle() at n/a:n/a
 call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
 Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
 Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531
 Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182
 Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265
 Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167
 Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826
 Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120
 Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123
 Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35

Checking the entry which caused the first error in MySQL db results in:

MariaDB [koel]> select * from albums where id=141;
+-----+-----------+----------+-------+----------------+---------------------+---------------------+
| id  | artist_id | name     | cover | is_compilation | created_at          | updated_at          |
+-----+-----------+----------+-------+----------------+---------------------+---------------------+
| 141 |        52 | ??nUnkwo |       |           NULL | 2017-08-18 08:02:06 | 2017-08-18 08:02:06 |
+-----+-----------+----------+-------+----------------+---------------------+---------------------+
1 row in set (0.00 sec)

and similarly for the second error

MariaDB [koel]> select * from songs where id = 'ce24f5dd9c07c0868917cde2efa3da44'\G;
*************************** 1. row ***************************
                    id: ce24f5dd9c07c0868917cde2efa3da44
              album_id: 314
contributing_artist_id: 157
                 title: Any Colour You Like
                length: 205.69
                 track: 7
                lyrics: ??
                  path: <redacted>/Pink Floyd/Dark Side Of The Moon/07 Any Colour You Like.mp3
                 mtime: 1250523022
            created_at: 2017-08-18 08:03:16
            updated_at: 2017-08-18 08:03:16
1 row in set (0.00 sec)

ERROR: No query specified

The characters are somehow accepted.

If it's not possible to sanitize in some way the characters it would be nice not to exit due to the exception as this results in failing to scan the rest of the library.
Thanks for the nice work!

Originally created by @svalo on GitHub (Aug 18, 2017). Original GitHub issue: https://github.com/koel/koel/issues/636 Hello, I'm encounering some issues while using postgres with koel, tryied with mariadb and did not have problems. I'm not sure whether this is an issue with koel itself or not. OS: archlinux Postgres version:9.6.3 MariaDB version:10.1.26-MariaDB Php version: 7.1.8 Koel is configured using php-fpm + nginx Issue is: While scanning koel excepts and dies with errors like ``` [Illuminate\Database\QueryException (22021)] SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0xff (SQL: select * from "albums" where ("artist_id" = 52 and "nam e" = ��nUnkwo) limit 1) Exception trace: () at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:647 Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607 Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326 Illuminate\Database\Connection->select() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1711 Illuminate\Database\Query\Builder->runSelect() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1696 Illuminate\Database\Query\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:462 Illuminate\Database\Eloquent\Builder->getModels() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:446 Illuminate\Database\Eloquent\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:71 Illuminate\Database\Eloquent\Builder->first() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:354 Illuminate\Database\Eloquent\Builder->firstOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329 Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341 Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/Album.php:65 App\Models\Album::get() at /srv/http/koel/app/Models/File.php:248 App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84 App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221 Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74 App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54 App\Console\Commands\SyncMedia->handle() at n/a:n/a call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531 Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182 Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265 Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167 Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826 Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189 Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120 Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123 Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35 [PDOException (22021)] SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0xff Exception trace: () at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:323 PDOStatement->execute() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:323 Illuminate\Database\Connection->Illuminate\Database\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:640 Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607 Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326 Illuminate\Database\Connection->select() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1711 Illuminate\Database\Query\Builder->runSelect() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1696 Illuminate\Database\Query\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:462 Illuminate\Database\Eloquent\Builder->getModels() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:446 Illuminate\Database\Eloquent\Builder->get() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:71 Illuminate\Database\Eloquent\Builder->first() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:354 Illuminate\Database\Eloquent\Builder->firstOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329 Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341 Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/Album.php:65 App\Models\Album::get() at /srv/http/koel/app/Models/File.php:248 App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84 App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221 Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74 App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54 App\Console\Commands\SyncMedia->handle() at n/a:n/a call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531 Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182 Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265 Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167 Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826 Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189 Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120 Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123 Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35 ``` and ``` [Illuminate\Database\QueryException (22021)] SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0xfe (SQL: insert into "songs" ("id", "title", "length", "track", "lyrics", "path", "mtime", "album_id", "contributing_artist_id", "updated_at", "created_at") values (ce24f5dd9c07c0868917cde2efa3da44, Any Colour You Like, 205.68812 5, 7, ��, <redacted>/Pink Floyd/Dark Side Of The Moon/07 Any Colour You Like.mp3, 1250523022, 318, 157, 2017-08-18 08:26:55, 2017-08-18 08:26:55)) Exception trace: () at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:647 Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607 Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:450 Illuminate\Database\Connection->statement() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:404 Illuminate\Database\Connection->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2116 Illuminate\Database\Query\Builder->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1242 Illuminate\Database\Eloquent\Builder->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:650 Illuminate\Database\Eloquent\Model->performInsert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:508 Illuminate\Database\Eloquent\Model->save() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:377 Illuminate\Database\Eloquent\Builder->Illuminate\Database\Eloquent\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/helpers.php:878 tap() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:378 Illuminate\Database\Eloquent\Builder->updateOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329 Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341 Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/File.php:277 App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84 App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221 Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74 App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54 App\Console\Commands\SyncMedia->handle() at n/a:n/a call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531 Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182 Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265 Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167 Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826 Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189 Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120 Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123 Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35 [PDOException (22021)] SQLSTATE[22021]: Character not in repertoire: 7 ERROR: invalid byte sequence for encoding "UTF8": 0xfe Exception trace: () at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:449 PDOStatement->execute() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:449 Illuminate\Database\Connection->Illuminate\Database\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:640 Illuminate\Database\Connection->runQueryCallback() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:607 Illuminate\Database\Connection->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:450 Illuminate\Database\Connection->statement() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:404 Illuminate\Database\Connection->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2116 Illuminate\Database\Query\Builder->insert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1242 Illuminate\Database\Eloquent\Builder->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:650 Illuminate\Database\Eloquent\Model->performInsert() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:508 Illuminate\Database\Eloquent\Model->save() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:377 Illuminate\Database\Eloquent\Builder->Illuminate\Database\Eloquent\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/helpers.php:878 tap() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:378 Illuminate\Database\Eloquent\Builder->updateOrCreate() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1329 Illuminate\Database\Eloquent\Model->__call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1341 Illuminate\Database\Eloquent\Model::__callStatic() at /srv/http/koel/app/Models/File.php:277 App\Models\File->sync() at /srv/http/koel/app/Services/Media.php:84 App\Services\Media->sync() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:221 Illuminate\Support\Facades\Facade::__callStatic() at /srv/http/koel/app/Console/Commands/SyncMedia.php:74 App\Console\Commands\SyncMedia->syncAll() at /srv/http/koel/app/Console/Commands/SyncMedia.php:54 App\Console\Commands\SyncMedia->handle() at n/a:n/a call_user_func_array() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87 Illuminate\Container\BoundMethod::callBoundMethod() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31 Illuminate\Container\BoundMethod::call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Container/Container.php:531 Illuminate\Container\Container->call() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:182 Illuminate\Console\Command->execute() at /srv/http/koel/vendor/symfony/console/Command/Command.php:265 Symfony\Component\Console\Command\Command->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Console/Command.php:167 Illuminate\Console\Command->run() at /srv/http/koel/vendor/symfony/console/Application.php:826 Symfony\Component\Console\Application->doRunCommand() at /srv/http/koel/vendor/symfony/console/Application.php:189 Symfony\Component\Console\Application->doRun() at /srv/http/koel/vendor/symfony/console/Application.php:120 Symfony\Component\Console\Application->run() at /srv/http/koel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:123 Illuminate\Foundation\Console\Kernel->handle() at /srv/http/koel/artisan:35 ``` Checking the entry which caused the first error in MySQL db results in: ``` MariaDB [koel]> select * from albums where id=141; +-----+-----------+----------+-------+----------------+---------------------+---------------------+ | id | artist_id | name | cover | is_compilation | created_at | updated_at | +-----+-----------+----------+-------+----------------+---------------------+---------------------+ | 141 | 52 | ??nUnkwo | | NULL | 2017-08-18 08:02:06 | 2017-08-18 08:02:06 | +-----+-----------+----------+-------+----------------+---------------------+---------------------+ 1 row in set (0.00 sec) ``` and similarly for the second error ``` MariaDB [koel]> select * from songs where id = 'ce24f5dd9c07c0868917cde2efa3da44'\G; *************************** 1. row *************************** id: ce24f5dd9c07c0868917cde2efa3da44 album_id: 314 contributing_artist_id: 157 title: Any Colour You Like length: 205.69 track: 7 lyrics: ?? path: <redacted>/Pink Floyd/Dark Side Of The Moon/07 Any Colour You Like.mp3 mtime: 1250523022 created_at: 2017-08-18 08:03:16 updated_at: 2017-08-18 08:03:16 1 row in set (0.00 sec) ERROR: No query specified ``` The characters are somehow accepted. If it's not possible to sanitize in some way the characters it would be nice not to exit due to the exception as this results in failing to scan the rest of the library. Thanks for the nice work!
Author
Owner

@djelic commented on GitHub (Sep 7, 2017):

Tripped on this one too, solved by wrapping fetching $lyrics in utf8_encode here app/Models/File.php.
Not sure if it is the best solution but I agree that sync should not fail because of single track.

<!-- gh-comment-id:327788873 --> @djelic commented on GitHub (Sep 7, 2017): Tripped on this one too, solved by wrapping fetching `$lyrics` in `utf8_encode` here [app/Models/File.php](https://github.com/phanan/koel/blob/v3.6.2/app/Models/File.php#L170). Not sure if it is the best solution but I agree that sync should not fail because of single track.
Author
Owner

@phanan commented on GitHub (Dec 29, 2023):

Each scan is wrapped in a try//catch now.

<!-- gh-comment-id:1872222506 --> @phanan commented on GitHub (Dec 29, 2023): Each scan is wrapped in a try//catch now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#455
No description provided.