@marcel91200 / caddy Mirror · read-only / commits / 0a137e2f
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 04:45 UTC

caddyhttp: use errors.AsType for request body limit errors (#8090)

With the Go 1.26 floor, golangci-lint's modernize analyzer (errorsastype) flags the three errors.As calls that look for RequestBodyLimitError, which turned the Lint workflow red on master after #8056. Replace them with the generic errors.AsType; behavior is unchanged. Assistance disclosure: this change was made by an AI agent (Claude Sonnet 5.5, model ID claude-sonnet-5-5) acting as Matthew Holt's agent and under his approval. Build, go vet and the caddyhttp and caddyhttp/templates tests pass locally; golangci-lint itself was not run locally. Co-authored-by: Claude Code <noreply@anthropic.com>

Matt Holt committed Sep 30, 2026 at 13:50 UTC 0a137e2fafc3c3fffcd2f27c8ef0a78913165902
2 files changed +3 -6
modules/caddyhttp/templates/tplcontext.go
+1 -2
@@ -268,8 +268,7 @@ func (c TemplateContext) funcPlaceholder(name string) (string, error) {
268 // server renders the 413, and any other value, including unrelated
269 // errors, is converted to a string as before
270 if err, ok := value.(error); ok {
271 - var bodyLimit caddyhttp.RequestBodyLimitError
272 - if errors.As(err, &bodyLimit) {
271 + if bodyLimit, ok := errors.AsType[caddyhttp.RequestBodyLimitError](err); ok {
272 return "", caddyhttp.HandlerError{Err: bodyLimit, StatusCode: bodyLimit.StatusCode()}
273 }
274 }
modules/caddyhttp/vars.go
+2 -4
@@ -203,8 +203,7 @@ func (m VarsMatcher) MatchWithError(r *http.Request) (bool, error) {
203 // request_body max_size limit when {http.request.body} is
204 // truncated) instead of matching on its error text; unrelated
205 // errors are matched on their text as before
206 - var bodyLimit RequestBodyLimitError
207 - if errors.As(vv, &bodyLimit) {
206 + if bodyLimit, ok := errors.AsType[RequestBodyLimitError](vv); ok {
207 // wrap in a status-carrying handler error so the server
208 // renders the 413
209 return false, HandlerError{Err: bodyLimit, StatusCode: bodyLimit.StatusCode()}
@@ -350,8 +349,7 @@ func (m MatchVarsRE) MatchWithError(r *http.Request) (bool, error) {
349 // request_body max_size limit when {http.request.body} is
350 // truncated) instead of matching on its error text; unrelated
351 // errors are matched on their text as before
353 - var bodyLimit RequestBodyLimitError
354 - if errors.As(vv, &bodyLimit) {
352 + if bodyLimit, ok := errors.AsType[RequestBodyLimitError](vv); ok {
353 // wrap in a status-carrying handler error so the server
354 // renders the 413
355 return false, HandlerError{Err: bodyLimit, StatusCode: bodyLimit.StatusCode()}