Skip to content

fix: add validation to reject invalid characters in assignment ID#116

Open
Gasg10 wants to merge 2 commits intodrop-project-edu:v1.0.0-beta.5from
Gasg10:fix/98-backslash-assignment-id
Open

fix: add validation to reject invalid characters in assignment ID#116
Gasg10 wants to merge 2 commits intodrop-project-edu:v1.0.0-beta.5from
Gasg10:fix/98-backslash-assignment-id

Conversation

@Gasg10
Copy link
Copy Markdown

@Gasg10 Gasg10 commented Apr 21, 2026

Fixes #98

Problem

When creating an assignment with a backslash (\) in the ID field, the application returned an HTTP 404 error instead of a proper validation message.

Root Cause

The assignmentId field in AssignmentForm.kt had no pattern validation, so any character was accepted. When a backslash was submitted, the URL routing failed with 404.

Fix

Added a @Pattern annotation to the assignmentId field in AssignmentForm.kt to only allow letters, numbers, hyphens and underscores:

@field:NotEmpty(message = "Error: Assignment Id must not be empty")
@field:Pattern(regexp = "^[a-zA-Z0-9_-]+$", message = "Error: Assignment Id must only contain letters, numbers, hyphens and underscores")
var assignmentId: String? = null,

Testing

  1. Start the application locally
  2. Log in as teacher
  3. Navigate to Create Assignment
  4. Enter test\assignment in the ID field and fill the other required fields
  5. Click Save — a clear validation error message is now shown instead of a 404 error
image

@Gasg10 Gasg10 changed the base branch from master to v1.0.0-beta.5 April 21, 2026 20:31
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.

Creating an assignment with "\" in the ID results in HTTP 404 instead of validation error

2 participants