CLI-1839: Guard against missing 'type' key in oneOf loop#2025
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2025 +/- ##
=========================================
Coverage 92.49% 92.49%
- Complexity 1991 1992 +1
=========================================
Files 123 123
Lines 7232 7234 +2
=========================================
+ Hits 6689 6691 +2
Misses 543 543 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2025/acli.phar |
There was a problem hiding this comment.
Pull request overview
Guards ApiBaseCommand::castParamType() against oneOf schema entries that don’t define an inline type (e.g., unresolved $ref entries), preventing PHP warnings during parameter casting in generated API commands.
Changes:
- Skip
oneOfentries that lack thetypekey before accessing$type['type']. - Add a PHPUnit regression test to ensure typeless
oneOfentries don’t trigger warnings and integer casting still works.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Command/Api/ApiBaseCommand.php | Adds a type-key guard inside the oneOf casting loop to avoid undefined-key warnings. |
| tests/phpunit/src/Commands/Api/ApiCommandTest.php | Adds a regression test covering oneOf entries without type (e.g., $ref). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
castParamType accessed $type['type'] unconditionally inside the oneOf loop. A $ref entry (or any entry without an inline type) caused an "Undefined array key type" PHP Warning. Skip entries that lack the key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Addresses 4 medium severity advisories reported 2026-07-20: - GHSA-h95v-h523-3mw8: URI fragments disclosed in redirect Referer headers - GHSA-wm3w-8rrp-j577: Host-only cookie scope is not preserved - GHSA-f283-ghqc-fg79: Unbounded response cookies risk denial of service - GHSA-94pj-82f3-465w: Proxy-Authorization headers can be sent to origin servers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Summary
castParamTypeaccessed$type['type']unconditionally inside theoneOflooponeOfentry without an inlinetype(e.g. an unresolved$ref) triggered anUndefined array key "type"PHP Warningtypekey viaarray_key_existsguardRelated
$refs but left thisoneOfpath unguarded)Test plan
testCastParamTypeSkipsOneOfEntriesWithoutTypeKey— passes aoneOfspec with a typeless$refentry alongside anintegerentry; confirms the integer cast succeeds with no PHP warnings🤖 Generated with Claude Code