Skip to content

Reject oversized projects - #1082

Open
mwtrew wants to merge 5 commits into
mainfrom
scratch-project-size-limit
Open

mwtrew wants to merge 5 commits into
mainfrom
scratch-project-size-limit

Conversation

@mwtrew

@mwtrew mwtrew commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Status

Points for consideration:

  • Performance: this adds a DB query with some joins when a new asset is uploaded. However, this is only done when the new asset is about to be saved to S3 - it's skipped for existing assets. In the general case, the query will only run for one asset per burst of asset uploads, as all other assets will previously have been saved.

What's changed?

  • The Scratch asset upload endpoint now returns a 422 if saving the asset would mean the sum of stored assets for the project exceeds MAX_PROJECT_SIZE_MB. The status code was chosen due to limitations on the client side, and I have checked that a 422 is not returned in any other scenario.

Steps to perform after deploying to production

None.

@cla-bot cla-bot Bot added the cla-signed label Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Test coverage

94.13% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/40538008063

@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-scratch-pr-yexjea October 27, 2026 14:26 Inactive
@mwtrew
mwtrew marked this pull request as ready for review October 27, 2026 14:50
@mwtrew
mwtrew temporarily deployed to editor-api-p-scratch-pr-yexjea October 27, 2026 14:50 Inactive
Comment thread app/controllers/api/scratch/assets_controller.rb Outdated
Comment thread app/controllers/api/scratch/assets_controller.rb
As per Chris' suggestion here: #1051 (review)
…undation/editor-api into scratch-project-size-limit
@mwtrew
mwtrew temporarily deployed to editor-api-p-scratch-pr-yexjea October 27, 2026 15:21 Inactive

This branch was successfully deployed

1 active deployment
editor-api-p-scratch-pr-yexjea — f4b7a8de Deployed Oct 27, 2026 by mwtrew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants