Problem/Motivation

I am testing out the tools in the Tool Belt module for use in an MCP server (MCP Server Drupal module). When I try to call the entity_field_values tool with a valid entity artifact for the entity argument, I get the following PHP error:

Tool execution failed: Drupal\tool\ExecutableResult::success(): Argument #1 ($message) must be of type Drupal\Core\StringTranslation\TranslatableMarkup, string given, called in /tool_belt/modules/tool_belt_content/src/Plugin/tool/Tool/EntityFieldValues.php on line 116

Note that this only occurs if and when the tool call results in one or more fields being denied access. In that scenario, the $message variable sent to the success() method is actually a concatenation of two t() calls, which is likely why the error is hit.

Steps to reproduce

Because this tool requires an entity artifact for the argument, I don't know the best way to reproduce, but the tool can be executed from the Tool explorer in a scenario where there will be fields that are denied access, or as I noted, when the tool is invoked via an MCP server where there will be fields that are denied access.

Proposed resolution

Instead of trying to concatenate two distinct t() calls, there can be an ExecutableResult::success() call when there are field that are defined access and a call when there are not, with the relevant $message string and placeolders used. I have attached a patch with a local fix.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 executable-success-error-3590387-1.patch1.51 KBjaydub

Issue fork tool_belt-3590387

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jaydub created an issue. See original summary.

jaydub’s picture

StatusFileSize
new1.51 KB
jaydub’s picture

Status: Active » Needs review
michaellander’s picture

Good catch, @jaydub! Will test it out next week and pull it in if all looks good.

ajits made their first commit to this issue’s fork.

ajits’s picture

I was able to reproduce this with implementation of hook_entity_field_access in a custom module for one field and returning AccessResult::forbidden

  • ajits committed 605149d0 on 1.0.x
    fix: #3590387 Error on ExecutableResult::success call in...
ajits’s picture

Status: Needs review » Fixed

Thank you for the report and the patch! I have committed and pushed it to 1.0.x

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.