Skip to content

Validate version metadata to reject non-scalar types#3437

Merged
jlowin merged 2 commits intomainfrom
worktree-agent-aa5bffb6
Mar 7, 2026
Merged

Validate version metadata to reject non-scalar types#3437
jlowin merged 2 commits intomainfrom
worktree-agent-aa5bffb6

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Mar 7, 2026

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

@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 removed the enhancement Improvement to existing functionality. For issues and smaller PR improvements. label Mar 7, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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__,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@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 9ec4e7a into main Mar 7, 2026
7 checks passed
@jlowin jlowin deleted the worktree-agent-aa5bffb6 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unvalidated version metadata can trigger server errors

1 participant