{"record":{"id":"b4d74a88c7c381f1","repo":"caddyserver/caddy","slug":"provisioning-response-handler-d-w","errorCode":null,"errorMessage":"provisioning response handler %d: %w","messagePattern":"provisioning response handler (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/intercept/intercept.go","lineNumber":85,"sourceCode":"// CaddyModule returns the Caddy module information.\n//\n// EXPERIMENTAL: Subject to change or removal.\nfunc (Intercept) CaddyModule() caddy.ModuleInfo {\n\treturn caddy.ModuleInfo{\n\t\tID:  \"http.handlers.intercept\",\n\t\tNew: func() caddy.Module { return new(Intercept) },\n\t}\n}\n\n// Provision ensures that i is set up properly before use.\n//\n// EXPERIMENTAL: Subject to change or removal.\nfunc (irh *Intercept) Provision(ctx caddy.Context) error {\n\t// set up any response routes\n\tfor i, rh := range irh.HandleResponse {\n\t\terr := rh.Provision(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"provisioning response handler %d: %w\", i, err)\n\t\t}\n\t}\n\n\tirh.logger = ctx.Logger()\n\n\treturn nil\n}\n\nvar bufPool = sync.Pool{\n\tNew: func() any {\n\t\treturn new(bytes.Buffer)\n\t},\n}\n\n// EXPERIMENTAL: Subject to change or removal.\ntype interceptedResponseHandler struct {\n\tcaddyhttp.ResponseRecorder\n\treplacer     *caddy.Replacer","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/intercept/intercept.go#L67-L103","documentation":"Returned by Intercept.Provision when provisioning one of the configured handle_response entries fails; the inner error is wrapped with the 0-based index of the failing response handler. The Intercept module (EXPERIMENTAL) runs routes against buffered responses, and each handle_response route must itself provision successfully.","triggerScenarios":"Configuring `intercept` with `@matcher handle_response ...` blocks where one of the response routes contains an invalid nested handler/matcher — e.g. a bad matcher syntax or a handler module that fails its own Provision; the index in the message tells you which block.","commonSituations":"Using intercept with replace_error/handle_response patterns; a nested module that errors during provisioning (bad args); experimental API churn between Caddy versions breaking older configs.","solutions":["Use the index in the message to find the exact handle_response block (0-based) in your config and inspect the wrapped error for the root cause.","Fix or simplify the nested route — often a matcher typo or unsupported handler inside the response route.","Because intercept is experimental, align config syntax with your Caddy version's docs; adjust after upgrades.","Test with `caddy adapt` then `caddy validate` to isolate the failing block."],"exampleFix":"# before\nintercept {\n    @not_found status 404\n    handle_response @not_found {\n        rewrite * /not-found\n        bad_directive \"oops\"\n    }\n}\n# after\nintercept {\n    @not_found status 404\n    handle_response @not_found {\n        rewrite * /not-found\n        file_server\n    }\n}","handlingStrategy":"validation","validationCode":"# Adapt + validate in CI so a broken handle_response block fails before deploy\ncaddy adapt --config Caddyfile --pretty > /dev/null || exit 1\ncaddy validate --adapted-config <(caddy adapt --config Caddyfile) || exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep each handle_response block minimal; test nested handlers in isolation.","Track the experimental intercept API on upgrades — re-read docs before bumping Caddy versions.","Use the reported 0-based index to jump straight to the failing block when triaging."],"tags":["caddy","intercept","handle-response","provisioning","experimental"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}