Skip to content

fix(config): fail with a clear error when numeric env vars are malformed#150

Merged
Liohtml merged 1 commit into
mainfrom
claude/dependabot-prs-q6u94z
Jul 10, 2026
Merged

fix(config): fail with a clear error when numeric env vars are malformed#150
Liohtml merged 1 commit into
mainfrom
claude/dependabot-prs-q6u94z

Conversation

@Liohtml

@Liohtml Liohtml commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

MEDCHECK_PORT, MEDCHECK_MAX_VISION_IMAGES and MEDCHECK_MAX_DOWNLOAD_BYTES were parsed with bare int() inside dataclass default factories, so a typo like MEDCHECK_PORT=8080a crashed app/CLI startup with a raw ValueError traceback from deep inside dataclass construction. Values are now parsed via an _env_int helper that exits with a one-line error naming the variable and offending value. Silently falling back to the default was deliberately rejected — a wrong port or download cap should not be ignored.

Fixes #141

Changes

  • src/medcheck/core/config.py: new _env_int(name, default) helper — clear SystemExit on malformed values, default on unset/empty, tolerates surrounding whitespace; used for all three numeric fields
  • tests/unit/test_core/test_config.py: 4 new tests (malformed port, malformed byte cap, empty/whitespace → default, whitespace-padded valid value)

Testing

  • Existing tests pass (uv run pytest) — 172 passed
  • New tests added for new functionality — 4 new config tests
  • Coverage does not decrease (uv run pytest --cov-fail-under=85) — 87.14%
  • Linting passes (uv run ruff check .)
  • Type checking passes (uv run mypy src/medcheck --strict)
  • Pre-commit hooks pass — ruff hooks pass locally; full pre-commit not run

🤖 Generated with Claude Code

https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9


Generated by Claude Code

MEDCHECK_PORT, MEDCHECK_MAX_VISION_IMAGES and MEDCHECK_MAX_DOWNLOAD_BYTES
were parsed with bare int() inside dataclass default factories, so a typo
like MEDCHECK_PORT=8080a crashed startup with a raw ValueError traceback.
Parse via an _env_int helper that raises a one-line SystemExit naming the
variable and value (silently falling back would hide a misconfigured
port or cap). Empty/whitespace values use the default.

Fixes #141

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4svt5QTs4WUMSy4HwiVt9
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Liohtml, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 888bbe2a-86a7-4fd3-8f1c-c06558ec13c7

📥 Commits

Reviewing files that changed from the base of the PR and between 47d0084 and 4620d7a.

📒 Files selected for processing (2)
  • src/medcheck/core/config.py
  • tests/unit/test_core/test_config.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/dependabot-prs-q6u94z

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Liohtml Liohtml merged commit 63a57ac into main Jul 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[repo-health] Low: Settings crashes at startup with a raw ValueError when numeric env vars are malformed

2 participants