Skip to content

caddyhttp: return 413 for oversized body placeholders#7692

Open
cyphercodes wants to merge 1 commit into
caddyserver:masterfrom
cyphercodes:fix-request-body-placeholder-max-size-7691
Open

caddyhttp: return 413 for oversized body placeholders#7692
cyphercodes wants to merge 1 commit into
caddyserver:masterfrom
cyphercodes:fix-request-body-placeholder-max-size-7691

Conversation

@cyphercodes
Copy link
Copy Markdown
Contributor

Fixes #7691

Summary:

  • read request body placeholders with error handling instead of ignoring read errors
  • convert http.MaxBytesError from request_body max_size into an HTTP 413 handler error
  • propagate placeholder errors through templates and vars/vars_regexp matchers
  • add regression coverage for oversized {http.request.body} usage

Tests:

  • go test ./modules/caddyhttp ./modules/caddyhttp/templates -count=1
  • go test ./caddytest/integration -run 'TestRespondWithJSON|TestRequestBodyPlaceholderRespectsMaxSize' -count=1
  • git diff --check

Assistance Disclosure

This PR was implemented with assistance from Hermes Agent (OpenAI Codex/GPT-5.5). The changes were reviewed and verified with the targeted tests listed above.

@francislavoie
Copy link
Copy Markdown
Member

I agree with the concept, but the implementation might have too many side effects. Changing how errors for all placeholders are handled has far-reaching effects. Needs deeper analysis.

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.

Placeholder http.request.body truncates at max_size bytes, rather than producing a 413 error

2 participants