Skip to content

Omit parameters from empty Remote Config parameter groups - #1165

Merged
jeromegamez merged 2 commits into
beste:8.xfrom
stipic:fix-empty-parameter-group-serialization
Nov 17, 2026
Merged

jeromegamez merged 2 commits into
beste:8.xfrom
stipic:fix-empty-parameter-group-serialization

Conversation

@stipic

@stipic stipic commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #1164

What this does

ParameterGroup::toArray() always returned a parameters key. For a group without parameters, that was an empty PHP array, which is encoded as a JSON list. The Remote Config API expects a map there, so RemoteConfig::validate() and RemoteConfig::publish() failed for every template that contains an empty parameter group:

Invalid value at 'remote_config.parameter_groups[6].value' (Map), Cannot bind a list to map for field 'parameters'.

toArray() now leaves parameters out when the group is empty, the same way Parameter::toArray() leaves out empty conditionalValues. This is also how the API returns an empty group (#1132), so a fetched template is sent back the way it came in.

Backward compatibility

Only the array/JSON of an empty group changes: it no longer has a parameters key. RemoteConfigParameterGroupShape already declares parameters as optional since #1133, and groups with parameters are serialized as before. composer test:bc reports no backwards-incompatible changes.

Included

  • The fix in ParameterGroup::toArray()
  • ParameterGroupTest::testAnEmptyGroupIsSerializedWithoutParameters: the JSON of an empty group
  • ParameterGroupTest::testItCanBeCreated now also checks the JSON of a group with parameters
  • RemoteConfigTest::testValidateTemplateWithEmptyParameterGroup (integration): validates a template with an empty group against the live API, next to testValidateEmptyTemplate
  • CHANGELOG entry under Unreleased

Tests before and after the fix

With src/RemoteConfig/ParameterGroup.php from 8.x, the empty group test fails and shows the "parameters":[] that is sent to the API:

Parameter Group (Kreait\Firebase\Tests\Unit\RemoteConfig\ParameterGroup)
 ✔ It can be created
 ✘ An empty group is serialized without parameters
   ┐
   ├ Failed asserting that two strings are identical.
   ┊ ---·Expected
   ┊ +++·Actual
   ┊ @@ @@
   ┊ -'{"description":"description"}'
   ┊ +'{"description":"description","parameters":[]}'

With the fix:

Parameter Group (Kreait\Firebase\Tests\Unit\RemoteConfig\ParameterGroup)
 ✔ It can be created
 ✔ An empty group is serialized without parameters

Checks

  • composer pre-push: Rector, PHP-CS-Fixer and composer-normalize clean, PHPStan no errors, unit tests OK (371 tests, 567 assertions), BC check "No backwards-incompatible changes detected"
  • Run locally on PHP 8.5.4 only
  • The integration test was not run locally, because I don't have a Firebase test project. Without credentials it is skipped like the rest of the integration suite.

An empty parameter group was encoded with "parameters": [], a JSON list.
The Remote Config API expects a map and rejects the template with
"Cannot bind a list to map for field 'parameters'", so validate() and
publish() failed for every template containing an empty parameter group.
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff            @@
##                8.x    #1165   +/-   ##
=========================================
  Coverage     88.88%   88.89%           
- Complexity     1525     1526    +1     
=========================================
  Files           158      158           
  Lines          4275     4277    +2     
=========================================
+ Hits           3800     3802    +2     
  Misses          475      475           
Flag Coverage Δ Complexity Δ *Carryforward flag
emulator 40.79% <0.00%> (-0.02%) 1526.00 <0.00> (+1.00) ⬇️
grpc 3.91% <ø> (+<0.01%) 1525.00 <ø> (ø) Carriedforward from c292bb4
integration 72.18% <ø> (-0.02%) 1525.00 <ø> (ø) Carriedforward from c292bb4
unit 51.12% <100.00%> (+0.46%) 1526.00 <0.00> (+1.00)

*This pull request uses carry forward flags. Click here to find out more.

@jeromegamez jeromegamez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just two changes, and we're good to merge!

Comment thread tests/Unit/RemoteConfigTest.php Resolved
The request body test in RemoteConfigTest is dropped, validate() and
publish() serialize the group through ParameterGroup, which is tested.
@jeromegamez
jeromegamez merged commit c497dc9 into beste:8.x Nov 17, 2026
23 checks passed
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.

Remote Config: validate() and publish() fail for templates with an empty parameter group

2 participants