Skip to content

Raise ValueError for invalid boolean query params in resource templates#3434

Merged
jlowin merged 1 commit intomainfrom
worktree-agent-a3162c81
Mar 7, 2026
Merged

Raise ValueError for invalid boolean query params in resource templates#3434
jlowin merged 1 commit intomainfrom
worktree-agent-a3162c81

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Mar 7, 2026

Resource template boolean query parameters silently coerced any unrecognized string value to False?flag=banana would quietly become False instead of raising an error. The CLI's boolean parsing (client.py) already handled this correctly with explicit true/false sets; this applies the same pattern to template.py.

# Before: ?enabled=banana → False (silent)
# After:  ?enabled=banana → ValueError

@mcp.resource("config://settings{?enabled}")
def get_settings(enabled: bool = True) -> str:
    ...

Closes #3424

@jlowin jlowin added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. enhancement Improvement to existing functionality. For issues and smaller PR improvements. labels Mar 7, 2026
@marvin-context-protocol marvin-context-protocol Bot added server Related to FastMCP server implementation or server-side functionality. and removed enhancement Improvement to existing functionality. For issues and smaller PR improvements. labels Mar 7, 2026
@jlowin
Copy link
Copy Markdown
Member Author

jlowin commented Mar 7, 2026

Auto-reviewed and merging on behalf of @jlowin — CI is green (Windows OAuth proxy timeouts are pre-existing flaky tests).

@jlowin jlowin merged commit 9ccaef2 into main Mar 7, 2026
8 checks passed
@jlowin jlowin deleted the worktree-agent-a3162c81 branch March 7, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid boolean query parameter values silently coerced to False

1 participant