[PR #174] [MERGED] fix: return to break loop of $ref in schema, avoid some case of Custo… #184

Closed
opened 2026-02-15 21:15:15 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/174
Author: @bipedalBit
Created: 6/6/2025
Status: Merged
Merged: 6/8/2025
Merged by: @tjbck

Base: devHead: fix-circular-schema-ref-exception


📝 Commits (1)

  • 41fa151 fix: return to break loop of $ref in schema, avoid some case of Custom-field-not-found exception.

📊 Changes

3 files changed (+28 additions, -0 deletions)

View changed files

src/mcpo/tests/__init__.py (+0 -0)
📝 src/mcpo/tests/test_main.py (+15 -0)
📝 src/mcpo/utils/main.py (+13 -0)

📄 Description

…m-field-not-found exception.

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests to validate the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • When schema of tool has a $ref points to its parant node, it makes a circular reference and will cause a "Custom field not found" exception in function _process_schema_property().
  • return Any, Field(default=None, description="") in these cases to avoid exception.
  • I made the fix an atomic and pure incremental patch so it can't get worse than before.

Changed

  • return Any, Field(default=None, description="") in function _process_schema_property() when schema of tool has a $ref points to its parant node.

Fixed

  • Circular reference caused "Custom field not found" exceptions

Additional Information

Bug Scene

Schema from mcp-server-chart for example:

{
  "name": "generate_fishbone_diagram",
  "description": "Generate a fishbone diagram chart to uses a fish skeleton, like structure to display the causes or effects of a core problem, with the problem as the fish head and the causes/effects as the fish bones. It suits problems that can be split into multiple related factors.",
  "inputSchema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
      "data": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "children": {
            "type": "array",
            "items": {
              "properties": {
                "name": { "type": "string" },
                "children": {
                  "type": "array",
                  "items": {
                    "$ref": "#/properties/data/properties/children/items"
                  }
                }
              },
              "required": ["name"],
              "type": "object"
            }
          }
        },
        "required": ["name"],
        "description": "Data for fishbone diagram chart, such as, { name: 'main topic', children: [{ name: 'topic 1', children: [{ name: 'subtopic 1-1' }] }."
      },
      "theme": {
        "default": "default",
        "description": "Set the theme for the chart, optional, default is 'default'.",
        "enum": ["default", "academy"],
        "type": "string"
      },
      "width": {
        "type": "number",
        "description": "Set the width of chart, default is 600.",
        "default": 600
      },
      "height": {
        "type": "number",
        "description": "Set the height of chart, default is 400.",
        "default": 400
      }
    },
    "required": ["data"]
  }
}

Testing

  • Unittest case added and passed. Just do pytest in the project to check.
  • We can start mcp-server-chart with mcpo now:
    截图 2025-06-07 10-45-19
  • mcp-server-chart tools work with the fix in open-webui confirmed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/mcpo/pull/174 **Author:** [@bipedalBit](https://github.com/bipedalBit) **Created:** 6/6/2025 **Status:** ✅ Merged **Merged:** 6/8/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix-circular-schema-ref-exception` --- ### 📝 Commits (1) - [`41fa151`](https://github.com/open-webui/mcpo/commit/41fa15163174fadc0c3a33762b13e27851047a0c) fix: return to break loop of $ref in schema, avoid some case of Custom-field-not-found exception. ### 📊 Changes **3 files changed** (+28 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `src/mcpo/tests/__init__.py` (+0 -0) 📝 `src/mcpo/tests/test_main.py` (+15 -0) 📝 `src/mcpo/utils/main.py` (+13 -0) </details> ### 📄 Description …m-field-not-found exception. # Pull Request Checklist **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests to validate the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - When schema of tool has a $ref points to its parant node, it makes a circular reference and will cause a "Custom field not found" exception in function _process_schema_property(). - `return Any, Field(default=None, description="")` in these cases to avoid exception. - I made the fix an atomic and pure incremental patch so it can't get worse than before. ### Changed - `return Any, Field(default=None, description="")` in function _process_schema_property() when schema of tool has a $ref points to its parant node. ### Fixed - Circular reference caused "Custom field not found" exceptions --- # Additional Information ### Bug Scene Schema from [mcp-server-chart](https://github.com/antvis/mcp-server-chart) for example: ```json { "name": "generate_fishbone_diagram", "description": "Generate a fishbone diagram chart to uses a fish skeleton, like structure to display the causes or effects of a core problem, with the problem as the fish head and the causes/effects as the fish bones. It suits problems that can be split into multiple related factors.", "inputSchema": { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "data": { "type": "object", "properties": { "name": { "type": "string" }, "children": { "type": "array", "items": { "properties": { "name": { "type": "string" }, "children": { "type": "array", "items": { "$ref": "#/properties/data/properties/children/items" } } }, "required": ["name"], "type": "object" } } }, "required": ["name"], "description": "Data for fishbone diagram chart, such as, { name: 'main topic', children: [{ name: 'topic 1', children: [{ name: 'subtopic 1-1' }] }." }, "theme": { "default": "default", "description": "Set the theme for the chart, optional, default is 'default'.", "enum": ["default", "academy"], "type": "string" }, "width": { "type": "number", "description": "Set the width of chart, default is 600.", "default": 600 }, "height": { "type": "number", "description": "Set the height of chart, default is 400.", "default": 400 } }, "required": ["data"] } } ``` ### Testing - Unittest case added and passed. Just do `pytest` in the project to check. - We can start [mcp-server-chart](https://github.com/antvis/mcp-server-chart) with mcpo now: ![截图 2025-06-07 10-45-19](https://github.com/user-attachments/assets/8fcf6131-9871-4898-bb16-cc90732d7028) - [mcp-server-chart](https://github.com/antvis/mcp-server-chart) tools work with the fix in open-webui confirmed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 21:15:15 -05:00
yindo closed this issue 2026-02-15 21:15:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui/mcpo#184