Skip to content

fix(showcase): avatar upload rejected real photos (4 MiB → 10 MiB) + core regression test#106

Merged
joaomdsg merged 2 commits into
mainfrom
fix/showcase-avatar-upload-size
Jun 10, 2026
Merged

fix(showcase): avatar upload rejected real photos (4 MiB → 10 MiB) + core regression test#106
joaomdsg merged 2 commits into
mainfrom
fix/showcase-avatar-upload-size

Conversation

@joaomdsg

Copy link
Copy Markdown
Member

Symptom

Avatar upload "didn't work" on the showcase for normal photos.

Root cause

The showcase set maxUpload = 4 MiB, but typical phone photos are 3–8+ MiB. The multipart MaxBytesReader trips during parse and returns a bare 413 "request too large" — and because the avatar form is a full-page <form> submit (not a datastar fetch), the browser just navigates to that 413 page, so it looks like the upload silently failed.

Confirmed against the running instance:

  • 5 MiB multipart POST /_action/Upload413
  • sub-limit body → got past the size gate (404 on a bogus via_tab)

Fix

  • Raise maxUpload 4 MiB → 10 MiB (comfortably fits a full-res photo).
  • State the limit in the form hint (“… up to 10 MB.”).

via core was correct

The file-binding + plain-<form> POST + http.Redirect(303) path works as intended — it was the showcase's chosen limit that was too low. Added a root regression test (TestUpload_plainFormPostBindsFileAndReturnsHandlerRedirect) that reproduces the exact showcase contract end-to-end: a multipart <form> POST carrying via_tab as a form field binds the via.File, and the handler's 303 reaches the client unmangled (Via must not clobber it with a datastar/200 action response).

(Separately tracked in critique-council.md: T9-UX-413 — oversize uploads should fail with a friendly in-form message rather than a bare 413; that's a framework-level change.)

joaomdsg added 2 commits June 10, 2026 12:07
The showcase avatar upload "didn't work" for normal photos: maxUpload was
4 MiB, but typical phone photos are 3-8+ MiB, so MaxBytesReader returned a
bare 413 "request too large" page on a full-page form submit — looking like
the upload silently failed. Confirmed against the running instance: a 5 MiB
multipart POST to /_action/Upload → 413; a sub-limit body gets past the size
gate. Raise the cap to 10 MiB and state the limit in the form hint.

via core was correct — the file-binding + plain-form-POST + http.Redirect(303)
path works. Added a root regression test (TestUpload_plainFormPostBindsFileAnd
ReturnsHandlerRedirect) that reproduces the showcase contract end-to-end: a
multipart <form> POST with via_tab as a form field binds the via.File and the
handler's 303 reaches the client unmangled (Via must not overwrite it with a
datastar/200 action response).
@joaomdsg
joaomdsg merged commit 15a1373 into main Jun 10, 2026
4 checks passed
@joaomdsg
joaomdsg deleted the fix/showcase-avatar-upload-size branch June 10, 2026 12:17
joaomdsg added a commit that referenced this pull request Jun 10, 2026
#107)

An action POST exceeding the body cap (WithMaxRequestBody/WithMaxUploadSize)
trips MaxBytesReader before any action handler runs, so the only way to turn
the bare 413 "request too large" page into something friendly is a framework
hook. WithRequestTooLarge(h http.Handler) installs one (mirrors WithNotFound);
default behavior — a plain 413 — is unchanged.

Wire it in the showcase: a too-large avatar now bounces back to /app/profile
with a flag the page renders as an inline "image was over 10 MB" message via a
query-bound field, instead of dead-ending on a 413. Closes the T9-UX-413
follow-up to the avatar-upload fix (#106).

Root build + tests green under -race; viashowcase builds/vets/tests green.
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