Skip to content

Add configurable max output limit for site-managed problems#2452

Open
AdhamAbouaita wants to merge 2 commits intoDMOJ:masterfrom
AdhamAbouaita:output-limit-for-site-managed-problems
Open

Add configurable max output limit for site-managed problems#2452
AdhamAbouaita wants to merge 2 commits intoDMOJ:masterfrom
AdhamAbouaita:output-limit-for-site-managed-problems

Conversation

@AdhamAbouaita
Copy link
Copy Markdown

@AdhamAbouaita AdhamAbouaita commented Mar 28, 2026

Feature: Limits output sizes to prevent judge server crashes.

Implementation: Added DMOJ_PROBLEM_MAX_OUTPUT_LIMIT (default 100MB) and applied MaxValueValidator to ProblemData and ProblemTestCase fields.

Migration: Added 0153_problem_data_output_limit_validator.py to sync Django’s state. While it generates no SQL, it prevents makemigrations from flagging missing validators in future runs.

Closes #2447

Prevent users from setting excessively large output limits (e.g., 2GB)
that can crash judge servers. Adds DMOJ_PROBLEM_MAX_OUTPUT_LIMIT setting
(default 100MB) and MaxValueValidator on ProblemData and ProblemTestCase
output_limit fields, validated on save via existing ModelForm flow.
migrations.AlterField(
model_name='problemdata',
name='output_limit',
field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(104857600)], verbose_name='output limit length'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the pretense that this is actually configurable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the migration file entirely since validators are enforced in Python at the form level, not at the database level, so I felt it was a no-op that just hardcoded the limit value without actually doing anything useful.

Validators are enforced in Python, not at the DB level, so this
migration produced no SQL. Removing it to avoid a misleading hardcoded
value in the migration snapshot.
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.

Add limit on output limit for site-managed problems

2 participants