Error Drupal\serialization\Normalizer\TypedDataNormalizer::normalize()

Created on 18 January 2024, over 1 year ago
Updated 19 January 2024, over 1 year ago

Hello, I'm experiencing an issue at the /admin/commerce/orders/55846?_format=json REST endpoint due to the following error

TypeError: Drupal\serialization\Normalizer\TypedDataNormalizer::normalize(): Return value must be of type ArrayObject|array|string|int|float|bool|null, Drupal\commerce_order\Adjustment returned in Drupal\serialization\Normalizer\TypedDataNormalizer->normalize() (line 22 of /var/www/html/core/modules/serialization/src/Normalizer/TypedDataNormalizer.php). 

Drupal version 10.1.8, Commerce 8.x-2.33, No pending updates.

No issues with other endpoints like user. I'm wonder if is possible to exclude fields in order to fix this error or how can I debug this issue?

For the second hand there is noting special in order fields:

field_actication_codes (Boolean)
field_order_invoice (Text plain)
shipments (Entity reference (locked))

💬 Support request
Status

Closed: duplicate

Version

2.33

Component

Order

Created by

🇵🇱Poland adpo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @adpo
  • Status changed to Closed: duplicate over 1 year ago
  • 🇮🇱Israel jsacksick

    Duplicate of 🐛 [PP-1] Order's Adjustment can't be normalized and serialized Postponed .Closing this in favor of the other which has more comments and even patches.

  • 🇵🇱Poland adpo

    @jsacksick thank you for your reply , I have already tried PATH https://www.drupal.org/project/commerce/issues/2916252#comment-15287240 🐛 [PP-1] Order's Adjustment can't be normalized and serialized Postponed and https://www.drupal.org/project/commerce/issues/2916252#comment-15332776 🐛 [PP-1] Order's Adjustment can't be normalized and serialized Postponed without any success.

    I'm not convinced about any order's adjustment, is there a way to check this out?

    Here is the working example output before upgrade to Drupal 10:

    {
        "order_id": [
            {
                "value": 55819
            }
        ],
        "uuid": [
            {
                "value": "dad804c6-dbfb-47b9-ae0e-e1815eb8b7b9"
            }
        ],
        "type": [
            {
                "target_id": "default",
                "target_type": "commerce_order_type",
                "target_uuid": "affc6e26-74fc-4f11-b04e-6d7292a55d26"
            }
        ],
        "order_number": [
            {
                "value": "7997"
            }
        ],
        "version": [
            {
                "value": 12
            }
        ],
        "store_id": [
            {
                "target_id": 1,
                "target_type": "commerce_store",
                "target_uuid": "80851e61-b63a-4b32-b673-9aebe7c281a3",
                "url": "/store/1"
            }
        ],
        "uid": [
            {
                "target_id": 30866,
                "target_type": "user",
                "target_uuid": "4ab3bc14-be20-4c42-82ce-75c2e2f838cb",
                "url": "/user/30866"
            }
        ],
        "mail": [
            {
                "value": "test@test.com"
            }
        ],
        "ip_address": [
            {
                "value": "95.45.154.229"
            }
        ],
        "billing_profile": [
            {
                "target_id": 33525,
                "target_revision_id": 33519,
                "target_type": "profile",
                "target_uuid": "4c120c7c-d26b-49c2-9541-f85089cfbf9f",
                "url": "/profile/33525"
            }
        ],
        "order_items": [
            {
                "target_id": 38855,
                "target_type": "commerce_order_item",
                "target_uuid": "375944f4-2adc-4893-b0fe-7efb5ce414f3"
            }
        ],
        "adjustments": [
            {
                "value": {}
            }
        ],
        "total_price": [
            {
                "number": "187.000000",
                "currency_code": "EUR",
                "formatted": "€187.00"
            }
        ],
        "total_paid": [
            {
                "number": "187.000000",
                "currency_code": "EUR",
                "formatted": "€187.00"
            }
        ],
        "balance": [
            {
                "number": "0",
                "currency_code": "EUR",
                "formatted": "€0.00"
            }
        ],
        "state": [
            {
                "value": "processing"
            }
        ],
        "data": [
            {
                "paid_event_dispatched": true
            }
        ],
        "locked": [
            {
                "value": false
            }
        ],
        "created": [
            {
                "value": "2024-01-14T21:23:50+00:00",
                "format": "Y-m-d\\TH:i:sP"
            }
        ],
        "changed": [
            {
                "value": "2024-01-17T11:43:15+00:00",
                "format": "Y-m-d\\TH:i:sP"
            }
        ],
        "placed": [
            {
                "value": "2024-01-17T11:43:05+00:00",
                "format": "Y-m-d\\TH:i:sP"
            }
        ],
        "completed": [],
        "cart": [
            {
                "value": false
            }
        ],
        "checkout_flow": [
            {
                "target_id": "shipping",
                "target_type": "commerce_checkout_flow",
                "target_uuid": "8180c3d9-b151-4bd3-87df-d13fc3433dff"
            }
        ],
        "checkout_step": [
            {
                "value": "complete"
            }
        ],
        "payment_gateway": [
            {
                "target_id": "stripe",
                "target_type": "commerce_payment_gateway",
                "target_uuid": "e118e08c-6d0d-45cc-a103-9ff77d9ddbb8"
            }
        ],
        "payment_method": [
            {
                "target_id": 6459,
                "target_type": "commerce_payment_method",
                "target_uuid": "d8d89d66-fe30-47b0-b614-c07a06cf4e99"
            }
        ],
        "coupons": [],
        "field_order_activation_codes": [
            {
                "value": false
            }
        ],
        "field_order_invoice": [],
        "shipments": [
            {
                "target_id": 8183,
                "target_type": "commerce_shipment",
                "target_uuid": "946d8cca-3aeb-4ca3-9ec2-d4ca05de4765",
                "url": "/admin/commerce/orders/55819/shipments/8183"
            }
        ]
    }
  • 🇮🇱Israel jsacksick

    I'm not convinced about any order's adjustment, is there a way to check this out?

    Not sure what you mean by that?

  • 🇵🇱Poland adpo

    I believe I'm not making any order adjustments, other than discounts. Maybe there are some other modules that do it, should I do a research for a particular hook?

  • 🇮🇱Israel jsacksick

    Well, "other than discounts"? Discounts are represented by promotion adjustments (which would cause this error).

  • 🇵🇱Poland adpo

    Far enough, order load:

    [adjustments] => Array
                                    (
     [x-default] => Array
      (
      [0] => Array(1)
      )
      )
    
    
  • 🇵🇱Poland adpo

    problem solved with
    https://www.drupal.org/project/commerce/issues/2916252#comment-15332776 🐛 [PP-1] Order's Adjustment can't be normalized and serialized Postponed

Production build 0.71.5 2024