Skip to content

Bug: execute_custom_tool bypassed when unity_instance is specified in CLI /api/command endpoint #649

@coderabbitai

Description

@coderabbitai

Description

The execute_custom_tool handling in the /api/command REST endpoint is currently nested inside the "no unity_instance" else branch. This causes custom tool execution to be bypassed when a caller specifies both unity_instance and command_type: "execute_custom_tool". The request falls through to PluginHub.send_command instead of going through custom tool resolution and execution.

Affected Code

Context

This is a pre-existing logic issue in the CLI REST endpoint. The bug was identified during review of PR #644:

Expected Behavior

When command_type: "execute_custom_tool" is specified, the custom tool execution path should run regardless of whether unity_instance is provided.

Suggested Fix

Move the execute_custom_tool block outside the if/else so it runs before the final PluginHub.send_command call. The block should:

  1. Detect command_type == "execute_custom_tool"
  2. Validate params/tool_name/tool_params
  3. Use the already-resolved session_id/session_details
  4. Compute unity_instance_hint from unity_instance or session_details.hash
  5. Call resolve_project_id_for_unity_instance and CustomToolService.execute_tool
  6. Return the result without falling through to PluginHub.send_command

Reported by: @msanatan
Identified by: CodeRabbit review

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions