[PR #279] [CLOSED] fix: handle $ref to properties in schema processing #235

Closed
opened 2026-10-18 21:12:54 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/279
Author: @majiayu000
Created: 1/5/2026
Status: ❌ Closed

Base: dev ← Head: fix/issue-117-ref-to-properties


📝 Commits (1)

  • 23c4d3c fix: handle $ref to properties in schema processing

📊 Changes

2 files changed (+122 additions, -10 deletions)

View changed files

📝 src/mcpo/tests/test_main.py (+74 -0)
📝 src/mcpo/utils/main.py (+48 -10)

📄 Description

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:
    • fix: Bug fix or error correction

Changelog Entry

Description

When MCP servers use intra-schema property references like {"$ref": "#/properties/other_field"}, mcpo would crash with TypeError: argument of type 'NoneType' is not iterable or AssertionError: Custom field not found. This PR fixes the schema reference resolution to properly handle references to properties.

Fixed

  • Add root_properties parameter to _process_schema_property to enable resolving #/properties/ references
  • Properly resolve $ref references that point to sibling properties in the same schema
  • Handle #/$defs/ and #/definitions/ refs explicitly with proper error handling
  • Gracefully handle missing ref targets by returning Any type instead of crashing
  • Merge additional properties (like description) from referencing schema to resolved schema
  • Added comprehensive tests for various $ref resolution scenarios

Closes #117


🔄 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/279 **Author:** [@majiayu000](https://github.com/majiayu000) **Created:** 1/5/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/issue-117-ref-to-properties` --- ### 📝 Commits (1) - [`23c4d3c`](https://github.com/open-webui/mcpo/commit/23c4d3cd8789c7033db1a3633925fab078f2ff44) fix: handle $ref to properties in schema processing ### 📊 Changes **2 files changed** (+122 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/mcpo/tests/test_main.py` (+74 -0) 📝 `src/mcpo/utils/main.py` (+48 -10) </details> ### 📄 Description # 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: - **fix**: Bug fix or error correction # Changelog Entry ### Description When MCP servers use intra-schema property references like `{"$ref": "#/properties/other_field"}`, mcpo would crash with `TypeError: argument of type 'NoneType' is not iterable` or `AssertionError: Custom field not found`. This PR fixes the schema reference resolution to properly handle references to properties. ### Fixed - Add `root_properties` parameter to `_process_schema_property` to enable resolving `#/properties/` references - Properly resolve `$ref` references that point to sibling properties in the same schema - Handle `#/$defs/` and `#/definitions/` refs explicitly with proper error handling - Gracefully handle missing ref targets by returning `Any` type instead of crashing - Merge additional properties (like description) from referencing schema to resolved schema - Added comprehensive tests for various `$ref` resolution scenarios Closes #117 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-18 21:12:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/mcpo#235
No description provided.