Skip to content

fix(composer): say a file is too large before uploading it - #446

Merged
devswha merged 2 commits into
mainfrom
fix/attachment-size-message
Oct 5, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/attachment-size-message

Conversation

@devswha

@devswha devswha commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Change

A file over the 8 MB attachment limit was read whole, encoded and uploaded, and then the server's answer was shown as it came: /api/pane/image failed (413): file exceeds 8388608 bytes. For a 107 MB zip the message ended at the colon: the body (base64 in JSON, 142.7 MB) is past Bun's default 128 MB request limit, which answers 413 with an empty body before the route runs.

Now the browser checks the size before it reads the file:

  • uploadPaneImage throws AttachmentTooLargeError, and nothing is sent. Its message is the text shown, in the UI language: Too large to attach: site.zip (9.3 MB). A file can be up to 8 MB. The composer and the terminal's drop and paste already show an upload error's message, so both get it.
  • A batch dropped or pasted on the terminal with one file too large uploads none of it. Its paths are pasted together, and before this the files ahead of the large one were saved and then left unused.
  • The limit moves to shared/attachments.ts, so the browser and POST /api/pane/image use one number. The server's check and its 413 are unchanged.
  • The guide's Compose row says the limit.

The limit itself is not changed here; #445 is about raising it.

Validation

  • bun run typecheck, bun run build, bun run generate:types --check and bun run test:unit pass.
  • src/lib/api.test.ts: a file one byte over the limit is refused with no request made, and a file at the limit is sent. With the check removed from uploadPaneImage the test fails (the upload goes out and returns a path).
  • In a browser on a test herdr session, a pane the script created, with a 9.3 MB site.zip:
    • composer, desktop, English: the chip reads Failed and the note says Too large to attach: site.zip (9.3 MB). A file can be up to 8 MB.; no request to /api/pane/image.
    • composer, 390 px wide, Korean: 첨부하기에는 너무 큽니다: site.zip (9.3 MB). 파일은 8 MB까지 첨부할 수 있습니다., wrapped on two lines under the box; no request.
    • terminal, a drop of notes.txt and site.zip together: the same sentence in the terminal's notice; no request.
    • control: a 5-byte notes.txt attached in the composer is uploaded (200) and saved under the pane's .herdr-web-ui/.

A file over the 8 MB attachment limit was read whole, encoded and sent, and
the answer was shown as it came: "/api/pane/image failed (413): file exceeds
8388608 bytes", or nothing after the colon for a file past about 96 MB, which
Bun's 128 MB request limit refuses before the route runs.

uploadPaneImage checks the size first and throws AttachmentTooLargeError,
whose message names the file, its size and the limit in the UI language. The
composer and the terminal's drop and paste already show the error's message.
A batch dropped on the terminal with one file too large uploads none of it,
since its paths are pasted together.

The limit moves to shared/attachments.ts so the browser and POST
/api/pane/image use one number.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a42be12e-5b14-4471-a891-d6af6eacc6c9
📥 Commits

Reviewing files that changed from the base of the PR and between 7c5fe4e and bf63517.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • docs/guide.md
  • server/paste.ts
  • shared/attachments.ts
  • src/components/PaneTerminal.tsx
  • src/lib/api.test.ts
  • src/lib/api.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features
    • File attachments larger than 8 MB are rejected before upload, with an error showing the file name, its size, and the limit.
    • When uploading multiple files, all files are checked first; if any exceeds the limit, none are uploaded.
  • Documentation
    • The Compose guide now states the 8 MB attachment limit.

Walkthrough

The client and server now use a shared 8 MiB attachment limit. The client reports oversized files before upload and validates every file in a batch before uploading any. The guide, changelog, tests, and translations reflect these changes.

Changes

Attachment size validation

Layer / File(s) Summary
Shared limit and server checks
shared/attachments.ts, server/paste.ts, docs/guide.md, CHANGELOG.md
A shared 8 MiB constant supplies the server image-size checks. The guide and changelog document the limit and related behavior.
Client upload validation
src/lib/api.ts, src/components/PaneTerminal.tsx, src/lib/api.test.ts, src/lib/i18n.*.ts
The API reports oversized files with their name, size, and limit. Batch uploads validate all files before sending any. Tests cover over-limit and at-limit files, and Japanese, Korean, and Simplified Chinese translations were added.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: nahwan-kim

Merge Risk: ⚪ Minimal · up to bf635

This change shows a clear message for oversized attachments before uploading them, using the same 8 MB limit as the server. No merge-blocking risk was identified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to bf635

Early validation reduces unnecessary uploads without replacing server-side enforcement. No introduced security issue was established, but verification of the complete before-and-after behavior remains incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The inspected sensitive outcome is writing user-supplied attachment bytes on the selected machine. Storage resolves a pane from the session snapshot, chooses its working-directory attachment folder or configured fallback, sanitizes non-image names, and writes files with mode 0600.

Trust Boundaries and Controls

  • observed — Browser validation is an early rejection mechanism, not the server's trust boundary. Before route dispatch, the inspected server applies conditional access admission, same-origin checks for mutating API requests, and watch-only restrictions; the upload route then type-checks its payload and invokes server validation.

Resilience and Maintainability Implications

  • inferred — A machine switch does not rebind the originating terminal component's upload reference to another machine: the terminal is keyed by selectedMachineId, and its upload function captures that machine's identity. Unmount closes the old socket and disposes the terminal, although already-started uploads are not explicitly canceled.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 8 files. (2 skipped: 2 u…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly states the main change: show that a file is too large before uploading it.
Description check ✅ Passed The description includes the required Change and Validation sections and gives detailed behavior and test results. It does not include the screenshot or recording requested for UI changes, but the des…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@devswha
devswha merged commit 0beac6c into main Oct 5, 2026
12 checks passed
@devswha
devswha deleted the fix/attachment-size-message branch October 5, 2026 01:29
devswha added a commit that referenced this pull request Oct 5, 2026
Bumps package.json and herdr-plugin.toml to 0.3.50 and moves the
Unreleased notes under [0.3.50] - 2026-10-06, with the compare link.
Adds the PR link and credit the #471 entry was missing; every other
entry already carries them. Raises the remote PC bundle to 17: #470
changes the prompt answer route on the bridge, so a remote PC on bundle
16 keeps the old behaviour until its bridge is updated. Push the
`remote-v17` tag and let the bundle workflow publish before running
release.yml.

Known limits carried into the notes: Japanese and Chinese text uses the
device's fonts beside Pretendard; #469 stays open for what #470 does not
cover (answers after the first committing key, identical twin prompts,
screens no reader knows).

Carries #422 #423 #424 #425 #426 #435 #437 #439 #446 #447 #448 #452 #454
#455 #456 #457 #458 #459 #460 #461 #462 #463 #465 #466 #467 #468 #471
#473 #474 #475

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <[email protected]>
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