[PR #221] [CLOSED] fix: pass schema def #202

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

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/221
Author: @phi-friday
Created: 7/31/2025
Status: Closed

Base: devHead: fix-schema-defs


📝 Commits (2)

📊 Changes

1 file changed (+7 additions, -1 deletions)

View changed files

📝 src/mcpo/utils/main.py (+7 -1)

📄 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:
    • 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

Fixed an issue where schema_defs was not being passed when _process_schema_property was called recursively. This caused errors due to missing schema_defs in those recursive calls.

      |   File "/Users/***/git/python/repo/***/.venv/lib/python3.13/site-packages/mcpo/utils/main.py", line 126, in _process_schema_property
      |     type_hint, _ = _process_schema_property(
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~^
      |         _model_cache,
      |         ^^^^^^^^^^^^^
      |     ...<3 lines>...
      |         False,
      |         ^^^^^^
      |     )
      |     ^
      |   File "/Users/***/git/python/repo/***/.venv/lib/python3.13/site-packages/mcpo/utils/main.py", line 204, in _process_schema_property
      |     item_type_hint, _ = _process_schema_property(
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~^
      |         _model_cache,
      |         ^^^^^^^^^^^^^
      |     ...<4 lines>...
      |         schema_defs,
      |         ^^^^^^^^^^^^
      |     )
      |     ^
      |   File "/Users/***/git/python/repo/***/.venv/lib/python3.13/site-packages/mcpo/utils/main.py", line 112, in _process_schema_property
      |     assert ref in schema_defs, "Custom field not found"
      |            ^^^^^^^^^^^^^^^^^^
      | TypeError: argument of type 'NoneType' is not iterable
      +------------------------------------

Fixed

When calling _process_schema_property recursively, the schema_defs argument was not being passed. This caused the following assertion to fail:

    if "$ref" in prop_schema:
        ref = prop_schema["$ref"]
        if ref.startswith("#/properties/"):
            # Remove common prefix in pathes.
            prefix_path = model_name_prefix.split("_form_model_")[-1]
            ref_path = ref.split("#/properties/")[-1]
            # Translate $ref path to model_name_prefix style.
            ref_path = ref_path.replace("/properties/", "_model_")
            ref_path = ref_path.replace("/items", "_item")
            # If $ref path is a prefix substring of model_name_prefix path,
            # there exists a circular reference.
            # The loop should be broke with a return to avoid exception.
            if prefix_path.startswith(ref_path):
                # TODO: Find the exact type hint for the $ref.
                return Any, Field(default=None, description="")
        ref = ref.split("/")[-1]
        assert ref in schema_defs, "Custom field not found"
        prop_schema = schema_defs[ref]


🔄 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/221 **Author:** [@phi-friday](https://github.com/phi-friday) **Created:** 7/31/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-schema-defs` --- ### 📝 Commits (2) - [`a388edd`](https://github.com/open-webui/mcpo/commit/a388eddd0663e8407059953f585644ab23e338d8) fix: pass schema def - [`3b877fa`](https://github.com/open-webui/mcpo/commit/3b877fa8530912aa66cd18328745fd227083307f) fix: pass schema def ### 📊 Changes **1 file changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/mcpo/utils/main.py` (+7 -1) </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. - [ ] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) 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? - [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 Fixed an issue where `schema_defs` was not being passed when `_process_schema_property` was called recursively. This caused errors due to missing `schema_defs` in those recursive calls. ```python | File "/Users/***/git/python/repo/***/.venv/lib/python3.13/site-packages/mcpo/utils/main.py", line 126, in _process_schema_property | type_hint, _ = _process_schema_property( | ~~~~~~~~~~~~~~~~~~~~~~~~^ | _model_cache, | ^^^^^^^^^^^^^ | ...<3 lines>... | False, | ^^^^^^ | ) | ^ | File "/Users/***/git/python/repo/***/.venv/lib/python3.13/site-packages/mcpo/utils/main.py", line 204, in _process_schema_property | item_type_hint, _ = _process_schema_property( | ~~~~~~~~~~~~~~~~~~~~~~~~^ | _model_cache, | ^^^^^^^^^^^^^ | ...<4 lines>... | schema_defs, | ^^^^^^^^^^^^ | ) | ^ | File "/Users/***/git/python/repo/***/.venv/lib/python3.13/site-packages/mcpo/utils/main.py", line 112, in _process_schema_property | assert ref in schema_defs, "Custom field not found" | ^^^^^^^^^^^^^^^^^^ | TypeError: argument of type 'NoneType' is not iterable +------------------------------------ ``` ### Fixed When calling `_process_schema_property` recursively, the `schema_defs` argument was not being passed. This caused the following assertion to fail: ```python if "$ref" in prop_schema: ref = prop_schema["$ref"] if ref.startswith("#/properties/"): # Remove common prefix in pathes. prefix_path = model_name_prefix.split("_form_model_")[-1] ref_path = ref.split("#/properties/")[-1] # Translate $ref path to model_name_prefix style. ref_path = ref_path.replace("/properties/", "_model_") ref_path = ref_path.replace("/items", "_item") # If $ref path is a prefix substring of model_name_prefix path, # there exists a circular reference. # The loop should be broke with a return to avoid exception. if prefix_path.startswith(ref_path): # TODO: Find the exact type hint for the $ref. return Any, Field(default=None, description="") ref = ref.split("/")[-1] assert ref in schema_defs, "Custom field not found" prop_schema = schema_defs[ref] ``` --- --- <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:18 -05:00
yindo closed this issue 2026-02-15 21:15:18 -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#202