Skip to content

Let export_query and export_table_query accept an explicit null filename - #21

Open
vishalhabib99 wants to merge 1 commit into
apache:mainfrom
vishalhabib99:fix/export-filename-accept-null
Open

vishalhabib99 wants to merge 1 commit into
apache:mainfrom
vishalhabib99:fix/export-filename-accept-null

Conversation

@vishalhabib99

Copy link
Copy Markdown

export_query and export_table_query annotate filename as str = None, and both already treat None as "generate dump_<id>_<timestamp>". FastMCP turns that into {"default": null, "type": "string"}, so a client that sends the advertised default explicitly ({"filename": null}) is rejected before the tool runs.

Found with mcp-doctor (none_default_type), then reproduced with an in-memory fastmcp.Client on fastmcp 4.0.11 / mcp 2.3.0 (what fastmcp>=2.8.1 resolves to today), no IoTDB running:

Before:

export_query filename schema: {"default": null, "type": "string"}
  omitted:       Error calling tool 'export_query': export_query requires tree SQL dialect, ...   (tool body ran)
  explicit null: 1 validation error for call[export_query]
                 filename  Input should be a valid string [type=string_type, input_value=None, ...]
export_table_query: same validation error for explicit null

After (str | None = None):

export_query filename schema: {"anyOf": [{"type": "string"}, {"type": "null"}], "default": null}
  explicit null: Error calling tool 'export_query': export_query requires tree SQL dialect, ...   (tool body ran)
export_table_query: explicit null also reaches the tool body

Changes:

  • services/query.py: filename: str | None = None on both tools. Nothing else.
  • tests/test_tool_schemas.py: registers the query tools on a real FastMCP and checks that every parameter defaulting to None allows null. It fails on the current branch with ['export_query.filename', 'export_table_query.filename'] and passes with this change.

pytest tests: 93 passed, 26 subtests passed.

🤖 Generated with Claude Code

Both tools annotate filename as `str = None` and already treat None as
"generate a name". The schema then advertised "default": null on a
string-only field, and FastMCP rejected {"filename": null} before the
tool ran. Annotate it `str | None`.

Adds a test that every query tool parameter defaulting to None allows null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vishalhabib99

Copy link
Copy Markdown
Author

Hi, a quick follow-up. This still applies cleanly on main. It's two annotations (str = None to str | None = None) so export_query and export_table_query accept an explicit null filename (which they already treat as "generate a name"), plus a schema test. Let me know if you'd like anything changed.

@HTHou
HTHou requested a review from CRZbulabula October 16, 2026 03:42
@vishalhabib99

Copy link
Copy Markdown
Author

Hi! Just a gentle follow-up on this PR. It's ready from my side, and I'm happy to make any changes you'd like. Thanks for taking a look!

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.

1 participant