Skip to content

Conversation

@olaservo
Copy link
Member

Fixes #2035 - fetch server now properly handles null values for optional parameters.

Makes max_length, start_index, and raw parameters properly optional by using Optional[] types and handling null values gracefully.

This fixes the issue where LibreChat and other MCP clients pass explicit null values for optional parameters, which was causing Pydantic validation failures.

Generated with Claude Code

Make max_length, start_index, and raw parameters properly optional
by using Optional[] types and handling null values gracefully.

This fixes the issue where LibreChat passes explicit null values
for optional parameters, which was causing Pydantic validation
failures.

Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
@olaservo
Copy link
Member Author

@claude can you add tests to cover the scenarios from the original issue?

@claude
Copy link
Contributor

claude bot commented Aug 27, 2025

Claude finished @olaservo's task —— View job


Added comprehensive tests for null value handling scenarios from issue #2035

What I implemented

Complete test suite covering the original issue scenarios

I created a full test suite at src/fetch/tests/test_server.py with 12 test cases that cover:

Core Issue #2035 Tests

  • Explicit null values: Tests that LibreChat can send null/None for optional parameters without validation errors
  • Parameter omission: Tests that optional parameters can be completely omitted
  • Mixed scenarios: Tests mixing null values with actual values

Parameter Validation Tests

  • URL validation (invalid URLs properly rejected)
  • max_length bounds checking (gt=0, lt=1000000)
  • start_index validation (ge=0)
  • raw boolean parameter handling

Server Logic Tests

  • Verifies that None values are converted to defaults by server logic
  • Tests that explicit non-None values are preserved correctly
  • Validates the or operator logic in call_tool function

Key test scenarios from the original issue:

# This was failing before the fix
params = {
    "url": "https://example.com", 
    "max_length": None,    # LibreChat sends explicit null
    "start_index": None,   # LibreChat sends explicit null  
    "raw": None           # LibreChat sends explicit null
}
fetch = Fetch(**params)  # Now works without ValidationError

All 12 tests pass, confirming the fix properly handles the scenarios that were causing LibreChat integration failures.

Todo List

  • Read original issue fetch fails without optional settings #2035 to understand test scenarios
  • Examine current fetch server code and changes
  • Find existing test structure for fetch server
  • Check repository setup and dependencies
  • Create tests directory and test file for fetch server
  • Implement tests for null value handling scenarios
  • Add tests for omitted optional parameters
  • Run tests to ensure they pass (12/12 tests passing ✅)
  • Commit and push changes

The tests are now part of the PR and will help prevent regressions of the null value handling fix.


…ters

- Add test suite covering scenarios from issue #2035
- Test explicit null values for optional parameters
- Test omitted optional parameters
- Test parameter validation and edge cases
- Test server logic that converts None to defaults
- Verify LibreChat compatibility with null parameters

Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
@olaservo olaservo closed this Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetch fails without optional settings

2 participants