Skip to content

fix(mcp): tolerate malformed client env#7561

Open
yyswhsccc wants to merge 1 commit into
Scottcjn:mainfrom
yyswhsccc:codex/bounties-mcp-env-guard
Open

fix(mcp): tolerate malformed client env#7561
yyswhsccc wants to merge 1 commit into
Scottcjn:mainfrom
yyswhsccc:codex/bounties-mcp-env-guard

Conversation

@yyswhsccc

Copy link
Copy Markdown
Contributor

Problem

rustchain-bounties-mcp/rustchain_bounties_mcp/client.py parsed RUSTCHAIN_TIMEOUT and RUSTCHAIN_RETRY directly at import time. A malformed local environment value raises ValueError before the MCP client can start.

Impact

A single bad numeric env value can crash the RustChain bounties MCP client during startup, preventing bounty/node tooling from initializing until the environment is corrected.

Fix

Add a small local _safe_int_env helper that logs malformed numeric env values and falls back to the existing defaults. Valid numeric env overrides are preserved.

Tests

  • uv run --no-project --with pytest --with pytest-asyncio --with aiohttp python -B -m pytest -q tests/test_client_miners.py -> 4 passed
  • python3 -m py_compile rustchain_bounties_mcp/client.py tests/test_client_miners.py -> passed
  • git diff --check -> passed

Boundaries

Related to the general bug bounty surface (#305). This PR does not change payout amounts, wallet crediting, admin secrets, or production wallet behavior.

wallet: RTC47bc28896a1a4bf240d1fd780f4559b242bcd945

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines labels Jun 23, 2026
@yyswhsccc

Copy link
Copy Markdown
Contributor Author

@Scottcjn Please take a look when you have a chance. This is a small MCP client startup hardening fix: malformed RUSTCHAIN_TIMEOUT / RUSTCHAIN_RETRY values now fall back to existing defaults instead of crashing import/startup.

Validation:

  • uv run --no-project --with pytest --with pytest-asyncio --with aiohttp python -B -m pytest -q tests/test_client_miners.py -> 4 passed
  • python3 -m py_compile rustchain_bounties_mcp/client.py tests/test_client_miners.py -> passed
  • git diff --check -> passed

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Code reviewed - implementation verified.

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Code reviewed - implementation verified. Good work on the changes.

@jaxint

jaxint commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Nice implementation! This is a valuable contribution.

Reviewed for Bounty #71
Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants