Validate edit_pr no-fields before authentication #43

Closed
opened 2026-07-02 02:06:26 -05:00 by jcwalker3 · 0 comments
Owner

Problem

tests/test_mcp_server.py::TestEditPR::test_edit_pr_no_fields_raises can fail in environments without Gitea credentials because gitea_edit_pr calls _auth(...) before checking whether any editable field was provided. A validation-only failure (no fields) then surfaces as a RuntimeError (no credentials) instead of the intended ValueError.

Expected behavior

When gitea_edit_pr is called with no editable fields (title/body/state/base all None), it raises the intended validation error before attempting authentication, profile resolution, or any Gitea/API call.

Why

Validation-only failures must not depend on credentials, network, or environment configuration.

Scope

  • Move the no-fields validation ahead of _auth/URL setup in gitea_edit_pr (mcp_server.py).
  • Preserve behavior when fields are provided.
  • No change to auth behavior, retry/backoff, audit, config profiles, or worktree helpers. No secrets/env changes.

Tests

  • No-fields call raises the intended ValueError.
  • The no-fields path calls neither auth nor api_request.
  • Existing edit-PR success/error tests still pass.

Acceptance

  • No-fields validation happens before auth; the no-fields test passes without Gitea credentials; full suite passes; diff narrow.
## Problem `tests/test_mcp_server.py::TestEditPR::test_edit_pr_no_fields_raises` can fail in environments without Gitea credentials because `gitea_edit_pr` calls `_auth(...)` before checking whether any editable field was provided. A validation-only failure (no fields) then surfaces as a `RuntimeError` (no credentials) instead of the intended `ValueError`. ## Expected behavior When `gitea_edit_pr` is called with no editable fields (`title`/`body`/`state`/`base` all `None`), it raises the intended validation error **before** attempting authentication, profile resolution, or any Gitea/API call. ## Why Validation-only failures must not depend on credentials, network, or environment configuration. ## Scope - Move the no-fields validation ahead of `_auth`/URL setup in `gitea_edit_pr` (`mcp_server.py`). - Preserve behavior when fields are provided. - No change to auth behavior, retry/backoff, audit, config profiles, or worktree helpers. No secrets/env changes. ## Tests - No-fields call raises the intended `ValueError`. - The no-fields path calls neither auth nor `api_request`. - Existing edit-PR success/error tests still pass. ## Acceptance - No-fields validation happens before auth; the no-fields test passes without Gitea credentials; full suite passes; diff narrow.
jcwalker3 added the status:in-progress label 2026-07-02 02:06:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#43