{"record":{"id":"46e190cb4366db93","repo":"caddyserver/caddy","slug":"provision-s-v","errorCode":null,"errorMessage":"provision %s: %v","messagePattern":"provision (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"context.go","lineNumber":436,"sourceCode":"\t\t\t\tctx.cfg.failedApps[id] = err\n\t\t\t}\n\t\t}()\n\t}\n\n\tctx.ancestry = append(ctx.ancestry, val)\n\n\tif prov, ok := val.(Provisioner); ok {\n\t\terr = prov.Provision(ctx)\n\t\tif err != nil {\n\t\t\t// incomplete provisioning could have left state\n\t\t\t// dangling, so make sure it gets cleaned up\n\t\t\tif cleanerUpper, ok := val.(CleanerUpper); ok {\n\t\t\t\terr2 := cleanerUpper.Cleanup()\n\t\t\t\tif err2 != nil {\n\t\t\t\t\terr = fmt.Errorf(\"%v; additionally, cleanup: %v\", err, err2)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"provision %s: %v\", modInfo, err)\n\t\t}\n\t}\n\n\tif validator, ok := val.(Validator); ok {\n\t\terr = validator.Validate()\n\t\tif err != nil {\n\t\t\t// since the module was already provisioned, make sure we clean up\n\t\t\tif cleanerUpper, ok := val.(CleanerUpper); ok {\n\t\t\t\terr2 := cleanerUpper.Cleanup()\n\t\t\t\tif err2 != nil {\n\t\t\t\t\terr = fmt.Errorf(\"%v; additionally, cleanup: %v\", err, err2)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"%s: invalid configuration: %v\", modInfo, err)\n\t\t}\n\t}\n\n\tctx.moduleInstances[id] = append(ctx.moduleInstances[id], val)","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/context.go#L418-L454","documentation":"LoadModuleByID calls Provision(ctx) on modules implementing the Provisioner interface so they can set themselves up (resolve dependencies, allocate clients). Any error returned is wrapped as 'provision %s: %v' with the ModuleInfo string identifying the module. The inner error text is the module's own and is the actual diagnosis.","triggerScenarios":"A module's Provision returns an error — invalid option combinations, missing required config, failed dependency lookup via ctx.App/ctx.LoadModule, environment problems (unreachable endpoint, bad credentials referenced at provision time).","commonSituations":"TLS/ACME modules failing on bad issuer config; plugins requiring non-nil fields that JSON left empty; Provision calling ctx.App for an app that itself failed to provision; permission errors opening storage paths.","solutions":["Identify the module from the ModuleInfo text in the error and read the inner error message — it states what provisioning could not do","Correct the module's config per its documented requirements (required fields, allowed values)","Check environmental prerequisites: storage permissions, reachable endpoints, env vars referenced with {env.*} placeholders","Search the module's source for the returned error string to understand the exact condition"],"exampleFix":"// before\n{ \"handler\": \"reverse_proxy\", \"upstream\": \"localhost:8080\" } // wrong field\n// after\n{ \"handler\": \"reverse_proxy\", \"upstreams\": [ { \"dial\": \"localhost:8080\" } ] }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := ctx.LoadModuleByID(id, raw); err != nil {\n    var msg string\n    if unwrapped := errors.Unwrap(err); unwrapped != nil { msg = unwrapped.Error() } else { msg = err.Error() }\n    return fmt.Errorf(\"module %s provisioning failed: %s\", id, msg)\n}","preventionTips":["Satisfy all documented required fields of the module in config","Check env/storage prerequisites before deploying configs that provision external clients","Validate configs in CI with `caddy validate`"],"tags":["caddy","module-system","provisioning","lifecycle"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}