Skip to content

refactor(web): align doctor diagnostics contracts - #548

Draft
magrhino wants to merge 1 commit into
mainfrom
codex/sonar-web-health-consistency
Draft

refactor(web): align doctor diagnostics contracts#548
magrhino wants to merge 1 commit into
mainfrom
codex/sonar-web-health-consistency

Conversation

@magrhino

Copy link
Copy Markdown
Owner

Summary

Align WebUI doctor option construction with its declared API and reduce the complexity of health diagnostic assembly without changing readiness, authentication, mutation, redaction, or response behavior.

  • Use argparse.Namespace for the doctor option parser's declared contract.
  • Group access checks and request-derived security checks into cohesive helpers while preserving check order, codes, statuses, details, and suggestions.
  • Add focused contract coverage for the namespace type and WebUI safety diagnostics.
  • Resolved Sonar issues: AZ6uKgZclZga0k7Gje-A, AZ6uKgZclZga0k7Gje-B.
  • Intentionally deferred from this PR: AZ9IUp3sJecd4IOuD73y in web_wud_api.py and AZ8QJXwzb5VpPISv262a in web_security.py; both are analyzer false positives and source changes would only silence Sonar.
  • Existing issue search found no matching open issue.

Scope

  • This PR has one reviewable objective
  • Follow-up work, stacked PRs, or intentionally deferred changes are called out here: digest lifecycle, init configuration, and scheduler selection remain independent cleanup PRs.

Checklist

  • Tests added or updated
  • README.md or docs/ updated if install, deployment, config, or user-facing behavior changed — N/A, no user-facing behavior changed
  • template.env updated if environment variables or example config changed — N/A, no configuration changed
  • CHANGELOG.md updated in ## [Unreleased] section — N/A, maintainability-only change

Test plan

  • tests/run-all.sh — N/A, full shell/container suite is outside this Python-only scope

  • Focused test(s):

    • .venv/bin/python -m pytest -q tests/test_python_web_health.py
    • .venv/bin/ruff check src/wudup/web_health.py tests/test_python_web_health.py
    • tests/run-all.sh --python
    • git diff --check
  • Docker or Compose validation, if container behavior changed: N/A, container behavior did not change

Sonar local file analysis was attempted twice for src/wudup/web_health.py; the MCP analyzer returned “Failed to request analysis of the list of files” both times.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a3736408-d953-4a4c-bbe0-713edd1b45e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@sourcery-ai

sourcery-ai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors WebUI doctor diagnostics to use argparse.Namespace for option construction and splits doctor checks into access and request-security helpers while adding a targeted test to lock in the diagnostics contract and behavior.

File-Level Changes

Change Details Files
Align doctor option construction with the declared argparse.Namespace contract and add coverage for it.
  • Replace use of types.SimpleNamespace with argparse.Namespace when building doctor options from web settings.
  • Ensure doctor_options_from_namespace is invoked with an argparse.Namespace instance.
  • Add a test that monkeypatches doctor_options_from_namespace to capture its argument and asserts it is an argparse.Namespace.
src/wudup/web_health.py
tests/test_python_web_health.py
Factor WebUI doctor checks into cohesive helpers without changing behavior or ordering.
  • Extract access-related doctor checks (authentication, mutation gate, allowed hosts) into a new _web_access_doctor_checks helper.
  • Extract request-derived security checks (public origin, secure cookies, trusted proxies) into a new _web_request_security_doctor_checks helper.
  • Reassemble the full _web_doctor_checks sequence to preserve check order while delegating to the new helpers and existing API diagnostics helpers.
src/wudup/web_health.py
Add focused WebUI safety diagnostics test ensuring codes, statuses, and suggestions remain unchanged.
  • Add test_doctor_endpoint_preserves_webui_safety_check_contract that exercises the /api/v1/doctor endpoint.
  • Assert presence of key WebUI safety check codes in the doctor response and verify specific status and suggestion snippet values for authentication and mutation gate checks.
tests/test_python_web_health.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown
Warnings
⚠️

Docker, Compose, or socket-adjacent files changed. Confirm Docker/Compose validation in the PR test plan, or add Danger: docker-review-complete with the reason.

Changed: src/wudup/web_health.py

Generated by 🚫 dangerJS against ee70b71

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.

1 participant