Skip to content

fix(upload): stop large photo batches failing as "network error"#2

Merged
Shaan-alpha merged 1 commit into
mainfrom
fix/upload-limits-network-error
Jun 4, 2026
Merged

fix(upload): stop large photo batches failing as "network error"#2
Shaan-alpha merged 1 commit into
mainfrom
fix/upload-limits-network-error

Conversation

@Shaan-alpha

Copy link
Copy Markdown
Owner

Problem

Uploading a real photo gallery failed with a red "Network error — is the server running?" toast right after clicking Start Sorting — even though the server was fine.

Root cause: a real gallery exceeds Werkzeug's 1000-part multipart limit and/or the byte cap. The dev server rejects an over-limit request before reading the body, so the browser (still uploading) sees the socket reset and fetch() throws — surfacing as a misleading "network error" instead of a clean message. Raising the byte cap alone (a prior fix) was whack-a-mole and never touched the separate 1000-part ceiling.

Fix

  • config — add MAX_UPLOAD_FILES (5000 local / 500 public, env-tunable via FACE_SORT_MAX_UPLOAD_FILES) and raise MAX_FORM_PARTS just above it so a valid batch is never reset; expose both limits to the page.
  • frontend — pre-flight the batch size/count before uploading and show a clear, actionable message (with a Local Folder nudge for big galleries) instead of letting the browser reset; parse the response defensively so an HTML error body isn't mislabeled as a network error.
  • tests — cover the new limits, env override, public-mode tightening, and acceptance of a batch over the historical 1000-part ceiling.

Verification

  • pytest tests/21 passed (6 new)
  • Manually verified end-to-end from source: uploads, SSE progress, results, and zip downloads all succeed.
  • node --check clean on app.js; template renders the injected limits.

🤖 Generated with Claude Code

A real gallery exceeds Werkzeug's 1000-part form limit and/or the byte
cap. The dev server rejects an over-limit request before reading the
body, so the browser (still uploading) sees the socket reset and reports
a misleading "Network error - is the server running?" instead of a clean
limit message. Raising the byte cap alone was whack-a-mole and never
touched the separate 1000-part ceiling.

- config: add MAX_UPLOAD_FILES (5000 local / 500 public, env-tunable) and
  raise MAX_FORM_PARTS above it (+ headroom) so a valid batch is never
  reset; expose the limits to the page.
- frontend: pre-flight the batch size/count before uploading and show a
  clear, actionable message (with a Local Folder nudge) instead of a
  reset; parse the response defensively so an HTML error body is not
  mislabeled as a network error.
- tests: cover the new limits, env override, public-mode tightening, and
  acceptance of a batch over the historical 1000-part ceiling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Shaan-alpha Shaan-alpha merged commit 8ba38cb into main Jun 4, 2026
3 checks passed
@Shaan-alpha Shaan-alpha deleted the fix/upload-limits-network-error branch June 4, 2026 20:38
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