Validate version metadata to reject non-scalar types#3437
Conversation
🤖 Generated with Claude Code
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6730dad8f3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fastmcp=self, | ||
| name=name or self.generate_name(), | ||
| version=version or fastmcp.__version__, | ||
| version=_coerce_version(version) or fastmcp.__version__, |
There was a problem hiding this comment.
Reject boolean server versions before coercion
The new constructor path version=_coerce_version(version) or fastmcp.__version__ changes behavior for version=False: _coerce_version(False) returns the truthy string "False", so the server now advertises "False" instead of falling back to the package version as before. This can happen when version values are sourced from config/env parsing and can propagate an invalid version string into metadata consumers that expect semantic-like versions.
Useful? React with 👍 / 👎.
|
Auto-reviewed and merging on behalf of @jlowin — CI is green (Windows OAuth proxy timeouts are pre-existing flaky tests). |
Version metadata accepted any type via `str(v)`, so passing a list or dict would silently produce versions like `"[1, 2]"` — confusing downstream. Now `_coerce_version` accepts `str | int | float | None`, coerces numeric types to strings, and raises `TypeError` for non-scalar types like lists and dicts. Same validation applied to `FastMCP.init`.
Closes #3422