Skip to content

Let the emoji upload limit be the one the owner set (GRYT-689) - #91

Merged
sivert-io merged 1 commit into
mainfrom
claude/GRYT-689-emoji-size-cap
Aug 29, 2026
Merged

Let the emoji upload limit be the one the owner set (GRYT-689)#91
sivert-io merged 1 commit into
mainfrom
claude/GRYT-689-emoji-size-cap

Conversation

@sivert-io

Copy link
Copy Markdown
Member

emojiMaxBytes clamps between 64 KB and 200 MB and defaults to 100 MB. The multer instance both emoji routes shared was a fixed 50 MB. An owner who set anything above that got a number the server would never honour, and the request died inside multer with a generic error rather than reaching the size check that has something useful to say.

This is the same bug uploads.ts already fixed for general uploads, and its comment describes it exactly:

There used to be two independent ceilings — a fixed 200 MB here and whatever the server was configured for — and the lower one silently won.

Same shape, same fix. emojiUpload(fields) builds multer per request from getServerConfig(), mirroring uploadToDisk(field) next door. Both POST /api/emojis and POST /api/emojis/stage use it.

What to look at

  • Memory storage stays. Every emoji is re-encoded through sharp immediately, so a temp file would be written and deleted for nothing — the reason uploads.ts gives for avatars. The consequence is that an owner who sets 200 MB is choosing to hold 200 MB per file in memory. That was already true of the avatar route, and it is now reachable for emoji.
  • No unlimited branch. clampBytes holds emojiMaxBytes to a 64 KB floor, so zero cannot be set through settings — unlike uploadMaxBytes, which has clampBytesAllowingZero. The maxBytes > 0 check is defensive for a zero written straight into the row, where { fileSize: 0 } would refuse every upload. Say the word if you would rather emoji got the unlimited option too; that is a one-line change in serverSettings.ts and a bigger decision.
  • The files field still has no maxCount, so a batch request can carry many files at the new per-file limit. That is unchanged by this PR and predates it, but it is more load-bearing now than at a fixed 50 MB.

tsc --noEmit clean.

Related

docs#78 drops the "capped at 50 MB" sentence docs#77 added. It is correct only once this merges, so merge this one first.

🤖 Generated with Claude Code

`emojiMaxBytes` clamps anywhere from 64 KB to 200 MB and defaults to 100 MB.
The multer instance both emoji routes shared was a fixed 50 MB. So an owner
who set anything above that got a number the server would never honour, and
the request died inside multer with a generic error instead of reaching the
size check that has something useful to say.

This is the same two-ceilings bug `uploadToDisk` in `uploads.ts` already
fixed for general uploads, and the comment there says so: "There used to be
two independent ceilings — a fixed 200 MB here and whatever the server was
configured for — and the lower one silently won." Same shape, same fix. The
emoji routes now build multer per request from `getServerConfig()`.

Memory storage stays. Every emoji is re-encoded through sharp immediately,
so a temp file would be written and deleted for nothing, which is the reason
`uploads.ts` gives for avatars.

Emoji do not get the upload route's unlimited-at-zero branch: `clampBytes`
holds this setting to a 64 KB floor, so zero cannot be set. The guard is
there for a zero written straight into the row, where `{ fileSize: 0 }`
would refuse every upload.

Docs said "capped at 50 MB" and are corrected in docs#78, which should land
with this rather than before it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sivert-io
sivert-io merged commit f2e9f4c into main Aug 29, 2026
2 checks passed
@sivert-io
sivert-io deleted the claude/GRYT-689-emoji-size-cap branch August 29, 2026 14:01
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.

1 participant