Skip to content

ToolsTab: anyOf/$ref enum not resolved; optional enum fields not clearable (appear required) #897

@Edison-A-N

Description

@Edison-A-N

Inspector Version

  • 0.17.2

Describe the bug

ToolsTab does not correctly handle input schema with anyOf/$ref/enum:

  • anyOf=[$ref, null] (e.g., role) is not resolved, so enum is lost and UI cannot render a dropdown.
  • When falling back to nested/complex rendering, ToolsTab passes a trimmed schema (type/properties/description/items only) to DynamicJsonForm, dropping anyOf/$ref/enum.
  • String enum select in ToolsTab has no clear/empty option; optional fields become effectively required after selection.

To Reproduce

  1. Open Inspector, Tools tab.
  2. Select a tool whose input schema matches the minimal schema below (role anyOf $ref|null, is_active boolean|null).
  3. Observe: role is not rendered as an enum dropdown; selecting a string enum (where present) cannot be cleared back to undefined/null.

Expected behavior

  • anyOf=[$ref, null] renders as a dropdown with enum values and supports null/clearing.
  • Optional enum fields can be cleared (undefined or null per schema).
  • Downstream forms receive full schema (including anyOf/$ref/enum) for accurate rendering.

Screenshots

  • N/A (UI shows non-dropdown for role; optional enum cannot be cleared).

Environment (please complete the following information):

  • OS: e.g. macOS (darwin 24.5.0)
  • Browser: e.g. Chrome xx

Additional context

  • Minimal inputSchema to reproduce:
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "role": {
      "title": "Role",
      "description": "Filter by role",
      "anyOf": [
        { "$ref": "#/$defs/UserRole" },
        { "type": "null" }
      ]
    },
    "is_active": {
      "title": "Is Active",
      "description": "Filter by active status",
      "anyOf": [
        { "type": "boolean" },
        { "type": "null" }
      ]
    }
  },
  "$defs": {
    "UserRole": {
      "title": "UserRole",
      "type": "string",
      "enum": ["customer", "admin", "moderator"]
    }
  }
}
  • Affected areas/files:

    • client/src/utils/schemaUtils.ts (normalizeUnionType)
    • client/src/components/ToolsTab.tsx
    • client/src/components/DynamicJsonForm.tsx
  • Suggested fixes (summary):

    • Resolve $ref within normalize (from inputSchema.$defs) and preserve enum as { type: "string", enum, nullable: true }.
    • Pass full property schema to DynamicJsonForm (avoid trimming anyOf/$ref/enum).
    • Add clear/empty option to enum selects (or cleanParams before calling the tool to omit optional empties).

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