← Back to Pull requests

test(issues): pin custom-action permissions and input validation #48

Closed
unknown closed this pull request without merging on Nov 27, 2026 18:26 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 11:07 UTC
Author

Adds backend/tests/test_issue_actions.py. It covers IssueViewSet custom-action behaviour that issues/tests.py doesn't already exercise:

  • Permissions: a user who is neither the reporter nor the assignee gets 403 on assign and update_status. Those actions are writable only because they're listed in MUTATING_ACTIONS.

  • assign: an inactive user is refused (400), a blank assignee_id unassigns, and a non-object JSON body is rejected.

  • update_status: a blank or unknown status is rejected and the issue stays unchanged.

  • create-for-project: both reporter and project are taken from the URL and the user, even when the body names others. A non-numeric project id returns 400, and anonymous callers get 401.
  • Mutation check: removing 'assign' from MUTATING_ACTIONS makes a test fail. The full backend suite passes and ruff is clean (153 on the merged tree with current main, Python 3.12). Two draft tests that duplicated existing ones were dropped: one for the missing-project case, and in d0c11d6 test_non_numeric_project_id_rejected, which repeated issues/tests.py::test_create_for_project_rejects_non_numeric_id (caught by Kilo; my first version of this body wrongly said the duplicate had already gone).

    Tests only. They were drafted with AI help (Z.ai GLM), then reviewed against the existing tests and run locally.

    <!-- devin-review-badge-begin -->

    ---

    <a href="https://app.devin.ai/review/mangeshraut712/bug-reporting-system/pull/48" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
    <!-- devin-review-badge-end -->

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Low Risk

    Adds pytest coverage only; no runtime or API behaviour changes.

    > Overview

    Adds backend/tests/test_issue_actions.py to lock in contracts for IssueViewSet custom actions assign, update_status, and create-for-project.

    > Coverage includes 403 when the caller is not reporter/assignee on mutating actions (behaviour tied to MUTATING_ACTIONS in get_permissions()), assign validation (inactive assignee, blank assignee_id unassigns, non-object JSON body), update_status rejection of blank/invalid status without persisting changes, and create-for-project forcing reporter and project from the authenticated user and URL regardless of request body, plus 401 when unauthenticated.

    > Tests only — no application code changes.

    > <sup>Reviewed by Cursor Bugbot for commit d0c11d6142f23ce0ad28e0a38d851b771cee7b77. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    ---

    Review follow-up (d0c11d6). Kilo found four issues; all four are addressed and each thread has the detail. In short: two tests asserted only the status code and now also assert the issue is unchanged, the unauthenticated-create test asserts nothing was created, and a duplicate test was removed. The added assertions were checked by injecting a write-before-validation bug into the view: the old tests passed against it and the new ones fail.

    Diff: 419 lines (+314 / -105) across 5 files Reviewer: mangeshraut712 Review duration: 3318m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.68) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.68 · 419 lines diff across 5 files
    0.68
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.361
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.068
    Real PR Conversation Timeline
    1 comments
    "Review active on #48"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 68.2% (HIGH) · Higher = larger blast radius
    68.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.9% · Safe to merge
    26.9%