WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@BlankEclair
Copy link
Member

@BlankEclair BlankEclair commented Sep 29, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Added stricter validation for the wiki argument, requiring it to end with “wiki” or “wikibeta”. Invalid values now fail early with a clear error message, preventing misconfiguration.
  • Tests

    • Introduced tests to confirm acceptance of valid beta database names and to verify that invalid names produce the expected error.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Walkthrough

Adds a validation in parse_args to ensure the wiki argument ends with "wiki" or "wikibeta", raising a ValueError if not. This check runs immediately after parsing and before existing --xml/--images validation. Corresponding tests were added to verify acceptance and rejection cases.

Changes

Cohort / File(s) Summary
Argument parsing validation
miraheze/mediawiki/mwimport.py
Inserted early validation in parse_args requiring wiki to end with "wiki" or "wikibeta"; raises ValueError('<wiki> must be a proper database name') on mismatch.
Tests
tests/test_mwimport.py
Added tests: acceptance of examplewikibeta; rejection of example with expected ValueError message.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor U as User
    participant CLI as mwimport CLI
    participant P as parse_args
    participant V as WikiName Validator

    U->>CLI: Run with args
    CLI->>P: parse_args(args)
    P->>V: Validate wiki suffix
    alt Invalid wiki name
        V-->>P: Fail
        P-->>CLI: raise ValueError("<wiki> must be a proper database name")
        note right of CLI: Early exit before --xml/--images checks
    else Valid wiki name
        V-->>P: OK
        P-->>CLI: Proceed to existing validations
        CLI-->>U: Continue normal flow
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • RhinosF1

Poem

A bunny taps keys with a cheerful squeak,
“Only proper wikis!” is the rule this week.
Beta or main, the suffix must stick,
Else—thump!—a ValueError lands quick.
Tests hop by, ears up, keen—
Now our imports stay neat and clean. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and succinctly summarises the primary change, namely the addition of a validation check for the database name in the mwimport tool, and clearly identifies the component affected without superfluous details.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe48124 and 32ac9f3.

📒 Files selected for processing (2)
  • miraheze/mediawiki/mwimport.py (1 hunks)
  • tests/test_mwimport.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/test_mwimport.py (1)
miraheze/mediawiki/mwimport.py (1)
  • parse_args (15-65)
🪛 Ruff (0.13.1)
miraheze/mediawiki/mwimport.py

45-45: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: deb
🔇 Additional comments (2)
miraheze/mediawiki/mwimport.py (1)

44-45: Validation matches expected Miraheze DB naming

Good call failing fast when the wiki name lacks the expected wiki/wikibeta suffix; that mirrors our database naming convention and keeps the error surface small.

tests/test_mwimport.py (1)

55-69: Tests cover both acceptance and rejection paths

Appreciate the paired positive/negative cases here—they lock in the intended behaviour for regular and beta databases while guarding against regressions.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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 and usage tips.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant