Skip to content

Guard default progress handler against total=0 notifications#3432

Merged
jlowin merged 1 commit intomainfrom
codex/fix-progress-handler-zerodivisionerror
Mar 7, 2026
Merged

Guard default progress handler against total=0 notifications#3432
jlowin merged 1 commit intomainfrom
codex/fix-progress-handler-zerodivisionerror

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Mar 7, 2026

Motivation

  • Prevent a client-side crash (ZeroDivisionError) in the default progress handler when an MCP server emits total=0, which could be abused by an untrusted or buggy server to abort tool execution.

Description

  • Update default_progress_handler to only compute a percentage when total not in (None, 0) and add an elif total == 0 branch that logs the raw progress/total string without dividing, and add test_default_progress_handler_handles_zero_total to tests/client/test_progress.py to cover the case.

Testing

  • Ran uv sync (succeeded), ran the full suite with uv run pytest -n auto (the repository-wide run reported unrelated failures/timeouts), ran uv run pytest tests/client/test_progress.py (4 passed), and attempted uv run prek run --all-files which failed to initialize hooks due to external network access to codespell (403).

Codex Task

🤖 Generated with GPT-5.2-Codex
@marvin-context-protocol marvin-context-protocol Bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. client Related to the FastMCP client SDK or client-side functionality. 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 44b8238 into main Mar 7, 2026
8 checks passed
@jlowin jlowin deleted the codex/fix-progress-handler-zerodivisionerror branch March 7, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. client Related to the FastMCP client SDK or client-side functionality. codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant