Fix media uploads rejected with a 0 byte storage quota - #91
Merged
Conversation
Every seeded plan was created without storage_limit, so it fell to the
column default of 0. Companies subscribed to one inherited a 0 byte quota
and the first media upload failed with "Storage limit exceeded". Seed the
three plans with real limits (5/25/100 GB) and backfill installs that
already have 0 quota plans and companies.
The quota check itself never counted the incoming upload either:
sum('size') on UploadedFile objects reads a property that does not exist
and always returned 0, so only files already stored were weighed. Sum
getSize() instead.
Plans can no longer be saved with a 0 GB limit, which is what produced
the dead quota in the first place.
Fixes #89
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #89
Root cause
PlanSeedercreated all three plans withoutstorage_limit, so they landed on the column default of0.assignPlan()copies the plan's limit onto the company, so every company on a seeded plan carried a 0 byte quota andMediaController::checkStorageLimit()rejected the very first upload with "Storage limit exceeded. Please delete files or upgrade plan".A second bug lived in the same check:
collect($files)->sum('size')reads asizeproperty thatUploadedFiledoes not have, so it always returned0and the incoming upload was never weighed against the limit. Only already-stored files counted.Changes
PlanSeeder: free/starter/professional now ship with 5/25/100 GB.2026_07_27_000001_backfill_plan_storage_limits: gives existing 0 quota plans 5 GB and re-syncs companies stuck on 0, so live installs recover without an admin editing every plan by hand.MediaController::checkStorageLimit(): sumgetSize()so the upload actually counts.Store/UpdatePlanRequest:storage_limitmin 1 GB, a 0 GB plan is not a usable plan.Verification
tests/Feature/MediaStorageLimitTest.php: upload succeeds under a real quota, is rejected when the incoming file exceeds it (this one fails without thegetSize()fix), and a 0 GB plan no longer validates.🤖 Generated with Claude Code