[PR #200] [CLOSED] fix the TypeError and NameError when running with Neo4j MCP server #203

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

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/200
Author: @yohei1126
Created: 7/14/2025
Status: ❌ Closed

Base: main ← Head: main


📝 Commits (1)

  • 06b1330 fix name error and type errror

📊 Changes

1 file changed (+15 additions, -10 deletions)

View changed files

📝 src/mcpo/utils/main.py (+15 -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:
    • 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

  • This will fix #198

Fixed

Fixed Error #1: TypeError: argument of type 'NoneType' is not iterable

Root Cause:

  • In the _process_schema_property function, when processing $ref references, the code tried to check assert ref in schema_defs]
  • However, schema_defs could be None, and you can't use the in operator on None

Fix Applied:

if schema_defs is None:
    # If schema_defs is None, we can't resolve the reference
    return Any, Field(default=None, description="")
assert ref in schema_defs, f"Custom field '{ref}' not found in schema definitions"

Impact: This prevented the initial startup crash when trying to resolve schema references.

Fix Error #2: NameError: Fields must not use names with leading underscores
Root Cause:

  • Pydantic v2 strictly rejects any field names starting with underscores (like _meta, _top, _filter)
  • The Neo4j MCP server was returning schema properties with such field names
  • The existing name_needs_alias function only checked for double underscores but not single underscore

Fix Applied:

def name_needs_alias(name: str) -> bool:
    """Check if a field name needs aliasing (if it starts with '_')."""
    return name.startswith("_")  # Changed from "__" to "_"

Plus implemented a comprehensive aliasing system that:

  • Strips leading underscores from field names
  • Uses original names as Pydantic aliases for JSON serialization
  • Handles naming conflicts with suffix counters
  • Applied consistently in both nested and top-level model fields
  • Impact: This allowed the server to properly handle JSON schemas with underscore-prefixed field names while maintaining API compatibility.

Additional Information

  • [Insert any additional context, notes, or explanations for the changes]
    • [Reference any related issues, commits, or other relevant information]

Screenshots or Videos

  • [Attach any relevant screenshots or videos demonstrating the changes]

🔄 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/200 **Author:** [@yohei1126](https://github.com/yohei1126) **Created:** 7/14/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`06b1330`](https://github.com/open-webui/mcpo/commit/06b133078338bc460fbb98e5e6dd9f4572aaa81b) fix name error and type errror ### 📊 Changes **1 file changed** (+15 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/mcpo/utils/main.py` (+15 -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: - **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 - This will fix #198 ### Fixed Fixed Error #1: TypeError: argument of type 'NoneType' is not iterable Root Cause: * In the _process_schema_property function, when processing $ref references, the code tried to check assert ref in schema_defs] * However, schema_defs could be None, and you can't use the in operator on None Fix Applied: ``` if schema_defs is None: # If schema_defs is None, we can't resolve the reference return Any, Field(default=None, description="") assert ref in schema_defs, f"Custom field '{ref}' not found in schema definitions" ``` Impact: This prevented the initial startup crash when trying to resolve schema references. Fix Error #2: NameError: Fields must not use names with leading underscores Root Cause: * Pydantic v2 strictly rejects any field names starting with underscores (like _meta, _top, _filter) * The Neo4j MCP server was returning schema properties with such field names * The existing name_needs_alias function only checked for double underscores but not single underscore Fix Applied: ``` def name_needs_alias(name: str) -> bool: """Check if a field name needs aliasing (if it starts with '_').""" return name.startswith("_") # Changed from "__" to "_" ``` Plus implemented a comprehensive aliasing system that: * Strips leading underscores from field names * Uses original names as Pydantic aliases for JSON serialization * Handles naming conflicts with suffix counters * Applied consistently in both nested and top-level model fields * Impact: This allowed the server to properly handle JSON schemas with underscore-prefixed field names while maintaining API compatibility. --- ### Additional Information - [Insert any additional context, notes, or explanations for the changes] - [Reference any related issues, commits, or other relevant information] ### Screenshots or Videos - [Attach any relevant screenshots or videos demonstrating the changes] --- <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:39 +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#203
No description provided.