Do not deploy ExApp environment variables with an empty default as the literal string Array - #970
Conversation
…as the literal string Array Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
📝 WalkthroughWalkthroughAdded 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f3f1a88d-6245-4a39-889c-85d8cc1f6a92
📒 Files selected for processing (4)
lib/Service/ExAppEnvVarsHelper.phplib/Service/ExAppService.phptests/php/Service/ExAppEnvVarsHelperTest.phptests/php/Service/ExAppServiceGetAppInfoTest.php
…s too Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/php/Service/ExAppServiceGetAppInfoTest.php (2)
159-185: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winExercise empty JSON values that become empty arrays.
The test uses
default => '', but the regression input can arrive as[]after XML/JSON round-tripping. Add a JSON variable withdefault => []. Also add a declared variable with an empty deploy-option override and assert that both variables are absent from the result.Suggested test additions
['name' => 'EMPTY', 'display-name' => 'Empty', 'default' => ''], ['name' => 'KEPT', 'display-name' => 'Kept', 'default' => 'v'], + ['name' => 'EMPTY_OVERRIDE', 'default' => 'v'], ['name' => 'TYPED', 'default' => 5], @@ - 'environment_variables' => ['KEPT' => 'overridden'], + 'environment_variables' => [ + 'KEPT' => 'overridden', + 'EMPTY_OVERRIDE' => '', + ],Change
EMPTYto usedefault => [], or add a separate array-valued case.The PR objective requires empty defaults and empty overrides to be omitted for JSON-info registrations.
207-223: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the complete invalid-name error contract.
This test covers an empty name but not a missing
namekey. Add a separate missing-name case. Replace the generic assertion with a field-specific assertion such as:Suggested assertion
- self::assertStringContainsString('invalid environment variable definition', $appInfo['error']); + self::assertStringContainsString("'name' must be a non-empty string", $appInfo['error']);The PR objective requires readable errors for both missing and empty names.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c59a46cc-b738-42c5-9f94-06fbf828363c
📒 Files selected for processing (2)
lib/Service/ExAppService.phptests/php/Service/ExAppServiceGetAppInfoTest.php
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/Service/ExAppService.php
An empty
<default></default>(or<default/>) element for a declared environment variable is parsed into an empty array by the simplexml/json roundtrip, slips past the empty-value filter and ends up in the container as the literal stringArray, for both Docker and Kubernetes deployments.Declared variables now go through a small
ExAppEnvVarsHelper(same pattern asExAppRouteHelper): every field is normalized to a string, so empty elements become empty strings and the existing filter drops them. A missing or empty<name>is rejected with a readable registration error instead of a fatalTypeError. Values already persisted in deploy options from earlier registrations heal on the next update, since stored options re-enter this path as overrides.Covered by unit tests at both the helper and the
getAppInfolevel, including cases that round-trip the real XML shapes from the issue.Fixes #969