Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Expected null or Object but is Array on StoreAPI Product Categories #9908

Closed
whywilson opened this issue Jun 20, 2023 · 3 comments · Fixed by #9962
Closed

Expected null or Object but is Array on StoreAPI Product Categories #9908

whywilson opened this issue Jun 20, 2023 · 3 comments · Fixed by #9962
Labels
focus: rest api Work impacting REST api routes. type: bug The issue/PR concerns a confirmed bug. type: community contribution

Comments

@whywilson
Copy link

whywilson commented Jun 20, 2023

Describe the bug

The return image of product categories should be null or object, but on some categories, it is an empty array.
The same issues happened on the image of /wp-json/wc/store/products/categories request.

To reproduce

Steps to reproduce the behavior:

  1. Access the product category with wp-json.
  2. Get the JSON content.
{
  "id": 233,
  "name": "Product Name",
  "slug": "product-name",
  "description": "Product description",
  "parent": 28,
  "count": 2,
  "image": [],   // not null or object, but array
  "review_count": 44,
  "permalink": ""
}

Expected behavior

Expected the image to be null or object.

Environment

WordPress

Core version: 6.2.2
WooCommerce version: 7.8.0

@whywilson whywilson added the type: bug The issue/PR concerns a confirmed bug. label Jun 20, 2023
@Aljullu
Copy link
Contributor

Aljullu commented Jun 21, 2023

Thanks for opening this issue, @whywilson! Could you diagnose in which cases it happens? I wasn't able to reproduce, unfortunately.

For reference, the image property is generated here:

https://github.com/woocommerce/woocommerce-blocks/blob/trunk/src/StoreApi/Schemas/V1/ProductCategorySchema.php#L88

Looking forward to your reply!

@whywilson
Copy link
Author

Thanks for opening this issue, @whywilson! Could you diagnose in which cases it happens? I wasn't able to reproduce, unfortunately.

For reference, the image property is generated here:

https://github.com/woocommerce/woocommerce-blocks/blob/trunk/src/StoreApi/Schemas/V1/ProductCategorySchema.php#L88

Looking forward to your reply!

Hi there,
I cannot reproduce the issues, but it happened on some specific categories.
All categories link
And search "image":[] to find more.

@Aljullu
Copy link
Contributor

Aljullu commented Jun 23, 2023

Thanks, @whywilson! I'm going to add this to our backlog so we can investigate it further.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: rest api Work impacting REST api routes. type: bug The issue/PR concerns a confirmed bug. type: community contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants