Skip to content

Fix: Prevent 500 POST errors via strict frontend schema validation during Round Creation#454

Open
ayushshukla1807 wants to merge 1 commit intohatnote:masterfrom
ayushshukla1807:gsoc-2026-ui-input-validation
Open

Fix: Prevent 500 POST errors via strict frontend schema validation during Round Creation#454
ayushshukla1807 wants to merge 1 commit intohatnote:masterfrom
ayushshukla1807:gsoc-2026-ui-input-validation

Conversation

@ayushshukla1807
Copy link
Copy Markdown

@ayushshukla1807 ayushshukla1807 commented Mar 30, 2026

Fixes #447.
Resolves Server 500 errors occurring when organizers attempted to submit NewCampaign or NewRound forms missing heavily required parameters that the DAO refused.

Technical Solution

I implemented a strict client-side validation schema inside the Campaign and Round form components. By asserting required parameter rules natively in the Vue bindings before the final Axios dispatch, we successfully prevent malformed UI packets from triggering catastrophic backend stack traces.

The guards are enforced in the following order:

  1. Deadline presence — blocks submission if deadline_date is null
  2. Round name — blocks empty or whitespace-only names
  3. Quorum/juror consistency — blocks invalid quorum values or quorum > 0 with 0 jurors assigned
  4. Import source — blocks category/CSV/file-list fields being empty on Round 1
  5. Threshold — blocks subsequent rounds advancing without a threshold selected

Architectural Diagram

sequenceDiagram
    participant User
    participant Form as Vue Template (RoundNew.vue)
    participant Guard as submitRound() Guard
    participant Axios as adminService

    User->>Form: Clicks Add Round (empty fields)
    Form->>Guard: Invokes submitRound()
    Guard-->>Form: Deadline missing? alertService.error()
    Guard-->>Form: Name empty? alertService.error()
    Guard-->>Form: Quorum invalid? alertService.error()
    Guard-->>Form: Category missing? alertService.error()
    Note over Guard: All guards pass
    Guard->>Axios: adminService.addRound(payload)
    Axios-->>Form: 200 OK
Loading

Verification (Local Dev)

Tested locally on http://localhost:5173 against a live Flask backend on port 5005.

Scenario Expected Result
Submit with no deadline Error toast shown, no Axios call ✅ Pass
Submit with blank name Error toast shown, no Axios call ✅ Pass
Submit with empty category Error toast shown, no Axios call ✅ Pass
Submit with valid fields Round created successfully ✅ Pass

pr_454_demo

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.

500 POST Error during empty round creation (Missing Frontend Schema Validation)

1 participant