I have upgraded Magento 2.1.5 to Magento 2.2.6 but after that I am getting error in running upgrade command:

Error converting field value in table quote_item_option where option_id=85330 using Magento\Framework\DB\DataConverter\SerializedToJson. Fix data or replace with a valid value. Failure reason: 'Unable to unserialize value, string is corrupted.'

I have followed this link to fix the issue but still it doesn't work.

What I do to fix? can anyone suggest the solution?

  • check for composer.lock file. if it doesn't exist then the error occurs
    – poonam
    Oct 20, 2023 at 14:07

6 Answers 6


I had this problem too. The issue is exactly what the error message is saying... the data is corrupt. For me the corruption looked as if the values had been clipped at the end.

For example, some of the values looked something like a:2:{s:3:"qty";s:1

The approach I took assumed that the data is currently bad and the good data is probably irretrievable.

First I did an SQL query that searched for similar values. SELECT value FROM quote_item_option WHERE code = 'info_buyRequest' AND value = 'a:2:{s:3:"qty";s:1';

Then, I just fixed the serialized data to the extent that it could be fixed... UPDATE quote_item_option SET value = 'a:1:{s:3:"qty";i:1;}' WHERE code = 'info_buyRequest' AND value = 'a:2:{s:3:"qty";s:1';

This resolved the problem for me.

  • @DJ i also fixed same way UPDATE quote_item_option SET value = NULL WHERE code="info_buyRequest"
    – matinict
    Mar 11, 2020 at 18:41

I also had the same issue and it seems to be flag table flag_data column (TEXT type) has to be changed (LONGTEXT type) since config file has more data which could not possible to store in TEXT length. Below queries will fix the issue;

UPDATE flag SET flag_data = '{"system":"","scopes":"","themes":""}' WHERE flag_code = 'config_hash';
UPDATE flag SET flag_data = '{}' WHERE flag_code = 'system_config_snapshot';

Then run below setup:upgrade and verify the fix;

bin/magento setup:upgrade

More info: https://github.com/magento/magento2/issues/11657


The solution in the linked post should work, or give you a good direction; maybe you have to apply some modifications to make it working in your special scenario.

The data stored there is not corrupt, it is serialized (https://www.php.net/manual/de/function.serialize.php). Magento used to do this in earlier versions. Only the new JSON parser thinks it's corrupt, because, well, it's obviously not JSON, and this parser only understands JSON :)

Removing the data will remove additional options from your customer's cart items, so that's really not a good idea...

Basically, you need to

  • unserialize the data
  • encode the data in JSON format
  • store it again

As @simonthesorcerer wrote the problem are the data in the database! In our case the migration of Magento from 2.1.15 to 2.3.3 thrown an exception in the field value of the quote_item_option table.

The error was the wrong lenght of a string mentioned in the serialized data:


and the correct one is


the "action_url" data has been set with 131 characters instead of 130!! fixing this the migration works!

Thanks to all who help me with stackexchange!


your error is Unable to serialize value magento 2. Please remember that if the magento version is < 2.2, the option is saved by serialize, in reverse, the version >= 2.2, it use json.

You can resolve it in file /vendor/magento/framework/Serialize/Serializer/Json.php by using this query:

   public function unserialize($string)
    $result = json_decode($string, true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        $result = @$this->unserialize($string);
            return $result;
        throw new \InvalidArgumentException("Unable to unserialize value. Error: " . json_last_error_msg());
    return $result;

I know it is not an answer but I want to say that I was in the same problem and already fixed it in file/vendor/magento/framework/Serialize/Serializer/Json.php by using exactly that query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.