Skip to content

Explain a too-large share instead of showing "server returned 413" - #623

Merged
erikdarlingdata merged 1 commit into
devfrom
fix/share-too-large-message
Sep 29, 2026
Merged

erikdarlingdata merged 1 commit into
devfrom
fix/share-too-large-message

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

Summary

  • nginx on the PlanShare server now accepts shares up to 10 MB (changed on the server today, not in this PR). nginx had no client_max_body_size, so its 1 MB default applied, while the app accepts 10 MB. Shares from 1 to 10 MB failed with "Share failed: server returned 413". I added client_max_body_size 10m; to the /api/ location, ran nginx -t, and reloaded.
  • This PR fixes what users see above 10 MB. nginx and Kestrel both still refuse those uploads. Neither sends a JSON error, so the web client showed "server returned 413". It now shows: "This plan is too large to share. The limit is 10 MB."
  • The nginx setting lives only on the server. The comment on the Kestrel limit now records it, so the three places that state 10 MB change together.

Changes

  • src/PlanViewer.Web/Services/PlanShareService.cs: a 413 without a JSON error gets the size message. When the server does send error text, that text still wins.
  • server/PlanShare/Program.cs: comment only. It names the nginx setting and the web client's message.
  • tests/PlanViewer.Core.Tests/PlanShareServiceTests.cs:
    • A new test covers both kinds of 413 reply: nginx's HTML page and Kestrel's empty body.
    • The existing server-text test gets one more case: a 413 that carries error text shows that text.

The server change

  • The backup of the old site file is /root/nginx-backups/stats.erikdarling.com.20260929T193036Z.
  • Before the change, a 2 MiB POST to /api/share got nginx's 413.
  • After the change:
    • 2 MiB and 9 MiB reach the app. The app answers 400, because the test body is a JSON array, not a share, so nothing was stored.
    • 11 MiB still gets nginx's 413.
  • nginx and planshare are both active.
  • The deploy workflow never writes the nginx site file, so a deploy will not undo this.

Test Plan

  • PlanShareServiceTests: 15 passed, 0 failed.
  • CI runs the full suite on this PR.
  • After the next release deploys the web viewer, a share over 10 MB shows the new message.

The Program.cs comment is under server/PlanShare/**, so the next release merge redeploys PlanShare with no change in behavior.

Generated with Claude Code

https://claude.ai/code/session_019tS6P95Dtzs4aeMpb1xqzX

nginx on the PlanShare server now allows 10 MB request bodies on /api/,
matching Kestrel's MaxRequestBodySize; before, its 1 MB default refused
1-10 MB shares first. Above 10 MB both still refuse the upload, and
neither sends a JSON error, so the web client showed "Share failed:
server returned 413". It now says the plan is too large to share and
names the limit. Server text still wins when a 413 carries one.

The Kestrel limit's comment now records the nginx setting, which lives
only on the server, so the three places that state 10 MB change together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019tS6P95Dtzs4aeMpb1xqzX
@claude

claude Bot commented Sep 29, 2026

Copy link
Copy Markdown

Reviewed: no findings. The 413 fallback runs only after the server's JSON error text is checked, so server text still wins. The tests cover the HTML (nginx) and empty-body (Kestrel) cases, and the size-limit comments point at all three places that hold the 10 MB limit. I didn't confirm that the nginx client_max_body_size 10m setting the new comment describes exists in the server config, since that config isn't in this repo.

@erikdarlingdata
erikdarlingdata merged commit 26f5c06 into dev Sep 29, 2026
3 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/share-too-large-message branch September 29, 2026 19:37
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