question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: on database migration: Unsupported product nesting level detected

See original GitHub issue

I updated the homeassistants grocy integration, which updates grocy to 3.1. After this i see this database migration error in grocy:

Error source: /var/www/grocy/services/DatabaseService.php:35

Error message: SQLSTATE[23000]: Integrity constraint violation: 19 Unsupported product nesting level detected (currently only 1 level is supported)

Stack trace: #0 /var/www/grocy/services/DatabaseService.php(35): PDO->exec() #1 /var/www/grocy/services/DatabaseMigrationService.php(63): Grocy\Services\DatabaseService->ExecuteDbStatement() #2 /var/www/grocy/services/DatabaseMigrationService.php(33): Grocy\Services\DatabaseMigrationService->ExecuteSqlMigrationWhenNeeded() #3 /var/www/grocy/controllers/SystemController.php(27): Grocy\Services\DatabaseMigrationService->MigrateDatabase() #4 /var/www/grocy/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(43): Grocy\Controllers\SystemController->Root() #5 /var/www/grocy/vendor/slim/slim/Slim/Routing/Route.php(384): Slim\Handlers\Strategies\RequestResponse->__invoke() #6 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\Routing\Route->handle() #7 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\MiddlewareDispatcher->handle() #8 /var/www/grocy/vendor/slim/slim/Slim/Routing/Route.php(341): Slim\MiddlewareDispatcher->handle() #9 /var/www/grocy/vendor/slim/slim/Slim/Routing/RouteRunner.php(84): Slim\Routing\Route->run() #10 /var/www/grocy/middleware/LocaleMiddleware.php(16): Slim\Routing\RouteRunner->handle() #11 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): Grocy\Middleware\LocaleMiddleware->__invoke() #12 /var/www/grocy/middleware/AuthMiddleware.php(31): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #13 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): Grocy\Middleware\AuthMiddleware->__invoke() #14 /var/www/grocy/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(59): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #15 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\RoutingMiddleware->process() #16 /var/www/grocy/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(107): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #17 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\ErrorMiddleware->process() #18 /var/www/grocy/middleware/CorsMiddleware.php(30): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #19 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): Grocy\Middleware\CorsMiddleware->__invoke() #20 /var/www/grocy/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #21 /var/www/grocy/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle() #22 /var/www/grocy/vendor/slim/slim/Slim/App.php(199): Slim\App->handle() #23 /var/www/grocy/app.php(106): Slim\App->run() #24 /var/www/grocy/public/index.php(45): require_once(‘…’) #25 {main}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Didgeridrewcommented, Jul 22, 2021

After rolling back to my backup again I was able to identify the 2 offending parent products by opening a copy of the db in sqlitestudio. Simply clearing the “parent product” field in the Grocy UI (which was editable, not greyed out) did not fix the problem… I had to delete the product/item in the UI, restart Home Assistant, and then apply the update to the Grocy add-on.

As you state in your reply to OP, both of the items were originally created by an external app (Pantry Party android app), but I’m pretty sure it was in Grocy v3.0.0. The child/parent products were also weird combinations (for instance tortillas as child to coffee) that I wouldn’t have done on purpose.

0reactions
berrndcommented, Jul 25, 2021

I’ve added a workaround to also handle having unsupported parent/child product nesting levels.

If you want to have this now, replace the file migrations/0130.sql with that one and the upgrade will work. (It simply clears the “Parent product” field for any nesting level > 1.)


Just for reference and reproducibility, here is a v3.0.1 (demo) database which has this problem (manually created - Chocolate, which is already a parent for Milk Chocolate and Dark Chocolate, is a child of Cookies at the same time):

grocy_v3.0.1_unsupported_product_nesting_level.zip

And only to note that again:

  • It was never possible via the UI/frontend to produce this situation
  • It was only possible via the API (or any tool/app which uses it) before v3.0.0
    • since v3.0.0 this is also enforced via the API/backend
Read more comments on GitHub >

github_iconTop Results From Across the Web

Storage Migration Service known issues - Microsoft Learn
Inventory or transfer fail when using credentials from a different domain. This issue is caused by a code defect in the Storage Migration ......
Read more >
Release Notes for Flyway Engine - Documentation
Bug fixes. Removed the parsing of nested multiline comments from Oracle. This is in line with their documentation that states nested multiline ...
Read more >
Nesting tables are unsupported | Confluence Cloud - Jira
We disabled the ability to create new nested tables. Your existing pages with nested tables are safe and you can still modify these...
Read more >
Troubleshooting migration tasks in AWS Database Migration ...
To solve this issue, the current approach is to first precreate the tables and primary keys in the target database. Then use a...
Read more >
Zero Downtime Migration Release Notes - Oracle Help Center
Solution: This is an issue that is being tracked with Bug 33308423. As a workaround, re-run the migration command substituting the -sourcesid option...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found