Skip to content

Fixed empty json attributes arrays being sent incorrectly#116

Merged
cb-alish merged 1 commit intomasterfrom
release/sdk-php/4.12.1
Dec 15, 2025
Merged

Fixed empty json attributes arrays being sent incorrectly#116
cb-alish merged 1 commit intomasterfrom
release/sdk-php/4.12.1

Conversation

@cb-alish
Copy link
Copy Markdown
Collaborator

v4.12.1 (2025-12-15)


Bug Fixes:

@cb-alish cb-alish merged commit 3b5dd4f into master Dec 15, 2025
@cb-alish cb-alish deleted the release/sdk-php/4.12.1 branch December 15, 2025 08:36
@ychedemois
Copy link
Copy Markdown

Actually this caused a regression :
fields that take a "list" value (as a php numeric array), now receive a JSON object with explicit numeric keys :

example :

$client->coupon()->createForItems([
    'id' => 'foo',
    'name' => 'foo',
    'discount_percentage' => 10.0,
    'apply_on' => 'each_specified_item',
    'item_constraints' => [[
        'constraint' => 'specific',
        'item_type' => 'plan',
        'item_price_ids' => ['some_price_id'],
    ]],
]);

--> Chargebee\Exceptions\InvalidRequestException  item_constraints[item_price_ids][0] : wrong format.

in the final JSON payload,
item_price_ids is now sent as {"0":"some_price_id"} (instead of ["some_price_id"])
and this format is rejected by the API server

--> maybe the JSON_FORCE_OBJECT param should be used only if the $params array to serialize is an empty array ?

@cb-alish cb-alish mentioned this pull request Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Field meta_data cannot be cleared because empty array is not converted to {}

3 participants