Skip to content

CLI-1839: Guard against missing 'type' key in oneOf loop#2025

Merged
deepakmishra2 merged 2 commits into
mainfrom
CLI-1839
Jul 21, 2026
Merged

CLI-1839: Guard against missing 'type' key in oneOf loop#2025
deepakmishra2 merged 2 commits into
mainfrom
CLI-1839

Conversation

@deepakmishra2

Copy link
Copy Markdown
Contributor

Summary

  • castParamType accessed $type['type'] unconditionally inside the oneOf loop
  • Any oneOf entry without an inline type (e.g. an unresolved $ref) triggered an Undefined array key "type" PHP Warning
  • Fix skips entries that lack the type key via array_key_exists guard

Related

Test plan

  • testCastParamTypeSkipsOneOfEntriesWithoutTypeKey — passes a oneOf spec with a typeless $ref entry alongside an integer entry; confirms the integer cast succeeds with no PHP warnings

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 20, 2026 06:04
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (0d9c5db) to head (b44aff8).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2025/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/2025/acli.phar
chmod +x acli.phar

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 oneOf entries that lack the type key before accessing $type['type'].
  • Add a PHPUnit regression test to ensure typeless oneOf entries 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.

Comment thread tests/phpunit/src/Commands/Api/ApiCommandTest.php
@deepakmishra2 deepakmishra2 changed the title fix(CLI-1839): guard against missing 'type' key in oneOf loop CLI-1839: Guard against missing 'type' key in oneOf loop Jul 20, 2026
@deepakmishra2 deepakmishra2 self-assigned this Jul 20, 2026
@deepakmishra2 deepakmishra2 added the bug Something isn't working label Jul 20, 2026
deepakmishra2 and others added 2 commits July 21, 2026 14:43
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>
Comment thread composer.lock

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The changes done was because composer audit --locked was failing due to these vulnerabilities and dependabot has not yet created a PR to fix this.

Image

@deepakmishra2
deepakmishra2 merged commit 582c1fb into main Jul 21, 2026
26 checks passed
@deepakmishra2
deepakmishra2 deleted the CLI-1839 branch July 21, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants