Soundboard upload limit double-counts staged clips and reads a stale count #31

Closed
opened 2026-09-12 01:51:03 -04:00 by jared · 0 comments
Owner

Severity: medium · Type: bug · Confidence: high

Location: src/app/components/soundboard-pack-view/SoundboardPackEditor.tsx:120-121,177-224

Problem

clipCount is already existing (minus deleted) + uploads.length, but the per-file guard inside handleFiles tests clipCount + uploads.length >= SOUNDBOARD_MAX_CLIPS, double-counting the staged uploads — so the editor starts refusing uploads well before 40 clips once anything is staged. Worse, clipCount and uploads are captured from the render closure and setUploads inside the loop does not update them, so the guard evaluates the same stale number for every file in the batch: selecting 60 files in one go uploads all 60 to the media repo and stages them past the cap. The file.size check has the same batch behaviour but is per-file so it still works.

How to trigger

with ~35 clips already in a pack, stage a few uploads and try to add one more (false "Soundboard is full"); or select 60 small files at once on an empty pack (no cap applied).

Suggested fix

track the running count in a local variable inside the loop (let count = clipCount;count += 1) and drop the extra + uploads.length.


Filed from the September 2026 client audit (branch lotus @ 4bea4895).

**Severity:** medium · **Type:** bug · **Confidence:** high **Location:** `src/app/components/soundboard-pack-view/SoundboardPackEditor.tsx:120-121,177-224` ### Problem `clipCount` is already `existing (minus deleted) + uploads.length`, but the per-file guard inside `handleFiles` tests `clipCount + uploads.length >= SOUNDBOARD_MAX_CLIPS`, double-counting the staged uploads — so the editor starts refusing uploads well before 40 clips once anything is staged. Worse, `clipCount` and `uploads` are captured from the render closure and `setUploads` inside the loop does not update them, so the guard evaluates the same stale number for every file in the batch: selecting 60 files in one go uploads all 60 to the media repo and stages them past the cap. The `file.size` check has the same batch behaviour but is per-file so it still works. ### How to trigger with ~35 clips already in a pack, stage a few uploads and try to add one more (false "Soundboard is full"); or select 60 small files at once on an empty pack (no cap applied). ### Suggested fix track the running count in a local variable inside the loop (`let count = clipCount;` … `count += 1`) and drop the extra `+ uploads.length`. --- _Filed from the September 2026 client audit (branch `lotus` @ 4bea4895)._
jared added this to the Audit 2026-09 · Medium & Low milestone 2026-09-12 01:51:03 -04:00
jared added the bugpriority: mediumarea: calls labels 2026-09-12 01:51:03 -04:00
jared self-assigned this 2026-09-12 01:51:03 -04:00
jared closed this issue 2026-09-12 19:46:19 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
2026-11-14
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#31