Skip to content

Conversation

@priethor
Copy link
Contributor

Fixes #89, making ToolsHandler accept both nested (as seen in handle_tool_call) and unnested error formats.

However, this fix surfaces an inconsistency in error formatting and raises a bigger question: should handle_tool_call, ExecuteAbilityAbility, DiscoverAbilitiesAbility, and GetAbilityInfoAbility use the same format, either nested or not?

Copilot AI review requested due to automatic review settings November 10, 2025 15:38
@github-actions
Copy link

github-actions bot commented Nov 10, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: priethor <[email protected]>
Co-authored-by: galatanovidiu <[email protected]>
Co-authored-by: justlevine <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.88%. Comparing base (c948b69) to head (ec8a993).
⚠️ Report is 1 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk      #90      +/-   ##
============================================
+ Coverage     81.87%   81.88%   +0.01%     
- Complexity      933      934       +1     
============================================
  Files            49       49              
  Lines          3216     3218       +2     
============================================
+ Hits           2633     2635       +2     
  Misses          583      583              
Flag Coverage Δ
unit 81.88% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances error handling in the ToolsHandler by adding support for both string and array error formats. The change provides defensive handling for $result['error'] values, checking if the error is a string before attempting to access it as an array.

Key Changes:

  • Added type checking for $result['error'] to handle both string and array formats
  • Maintains backward compatibility with existing array-based error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Resolved conflict in tests/Unit/Handlers/ToolsHandlerTest.php by keeping
both new tests: test_call_tool_with_string_error_from_execute (from this
branch) and test_call_tool_wraps_scalar_return_values (from trunk).
@galatanovidiu galatanovidiu self-requested a review December 8, 2025 22:21
Copy link
Contributor

@galatanovidiu galatanovidiu left a comment

Choose a reason for hiding this comment

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

LGTM! The fix correctly handles the inconsistent error formats between ability implementations. The type check elegantly handles both:

  • String errors (from ExecuteAbilityAbility)
  • Array errors with message key (from other abilities)

Good test coverage with test_call_tool_with_string_error_from_execute. Resolved the merge conflict by keeping both this PR's test and test_call_tool_wraps_scalar_return_values from trunk. All 587 tests pass.

Note: This is a targeted hotfix for 0.4.1. A more comprehensive solution addressing the underlying error format inconsistency will land in 0.5.0 as part of the architecture improvements.

@galatanovidiu galatanovidiu merged commit 42ec2ca into WordPress:trunk Dec 8, 2025
19 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.

ExecuteAbilityAbility returns incompatible error format with ToolsHandler causing generic error messages

2 participants