magento2: app:config:import fails - flag column 'flag_data' is too short ?

I got this error; Import failed: Unable to unserialize value, string is corrupted. when running php bin/magento app:config:import to import my app/etc/config.php.

It turns out, the importer does a comparison in \Magento\Config\Model\Config\Importer::import. To do this comparison, it retrieves a ‘flag’; the system_config_snapshot flag. This is saved in the database. The problem is; the flag_data column in the flag table in Magento 2 is a TEXT, which is too short; it can only hold 65535 characters! It therefore cuts off the serialized data, making it corrupt.

Maybe this is a solution; ALTER TABLE flag MODIFY flag_data LONGTEXT COMMENT 'Flag Data'; ?

Preconditions

  1. Magento 2.2

Steps to reproduce

  1. Dump a large enough configuration file and import it (message me for an example file, it contains client data but willing to share with Magento employees) – you should also be able to create a large config.php by inserting large data sets into the translation table, since it also exports i18n settings.

Expected result

  1. It should import app/etc/config.php

Actual result

  1. Message; Import failed: Unable to unserialize value, string is corrupted.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 14
  • Comments: 19 (11 by maintainers)

Most upvoted comments

I was also having this problem with app:config:import

  1. i counted the number of characters in the truncated json before i made the changes: 65534
  2. updated the table: ALTER TABLE flag MODIFY flag_data LONGTEXT; UPDATE flag SET flag_data = ‘{“system”:“”,“scopes”:“”,“themes”:“”}’ WHERE flag_code = ‘config_hash’; UPDATE flag SET flag_data = ‘{}’ WHERE flag_code = ‘system_config_snapshot’;
  3. Then I ran app:config:import >>> the config import worked and the flag table was updated
  4. then I was curious, how large is our config, so i went to count the json again, have a guess how many characters there were? 65534.

I have a feeling this issue may not be fixed with an sql update.

On 2.3.3 this workaround was successful:

ALTER TABLE flag MODIFY flag_data LONGTEXT;
UPDATE flag SET flag_data = '{"system":"","scopes":"","themes":""}' WHERE flag_code = 'config_hash';
UPDATE flag SET flag_data = '{}' WHERE flag_code = 'system_config_snapshot';
bin/magento app:config:import

To create a large enough config.php, use https://lipsum.lipsum.com/ to generate a minimum of 66000 bytes of text and place it for example in the default_custom_instructions field in config.php.

Then run php bin/magento app:config:import and run php bin/magento app:config:import again;

Processing configurations data from configuration file...
Import failed: Unable to unserialize value, string is corrupted.

Additional thought; app:config:dump dumps EVERYTHING.

ideally, there would be a mode that only dumps differences from the current config to the default values.