Skip to content

feat: limit request body size - #1073

Merged
jmattheis merged 1 commit into
gotify:masterfrom
TameTheGame:fix/max-body-bytes
Oct 14, 2026
Merged

jmattheis merged 1 commit into
gotify:masterfrom
TameTheGame:fix/max-body-bytes

Conversation

@TameTheGame

Copy link
Copy Markdown
Contributor

Closes #950

Adds a middleware in router.Create that wraps every request body in http.MaxBytesReader. The limit is set with GOTIFY_SERVER_MAX_BODY_BYTES (default 10 MiB, 0 disables it).

Oversized requests get a 413 from endpoints that bind JSON or form data. /plugin/{id}/config and the application image upload still return 500, since those handlers treat any read error as a server error. I left them unchanged as planned, but can switch them to 413 if you'd like.

go test -race ./... passes.

Wrap every request body in http.MaxBytesReader so oversized bodies are
cut off before they are read completely. The limit defaults to 10 MiB
and can be changed with GOTIFY_SERVER_MAX_BODY_BYTES (0 disables it).
@TameTheGame
TameTheGame requested a review from a team as a code owner October 12, 2026 22:03
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.58%. Comparing base (6a49e9c) to head (09f5f0b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1073      +/-   ##
==========================================
+ Coverage   76.54%   76.58%   +0.03%     
==========================================
  Files          68       68              
  Lines        3714     3720       +6     
==========================================
+ Hits         2843     2849       +6     
  Misses        658      658              
  Partials      213      213              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jmattheis jmattheis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jmattheis
jmattheis added this pull request to the merge queue Oct 14, 2026
Merged via the queue into gotify:master with commit 05b93c3 Oct 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Limit body size for all requests

2 participants