{"record":{"id":"4187f96c3f8306fa","repo":"caddyserver/caddy","slug":"w-at-s-d","errorCode":null,"errorMessage":"%w, at %s:%d","messagePattern":"%w, at (.+?):(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"caddyconfig/caddyfile/dispenser.go","lineNumber":447,"sourceCode":"\treturn d.Errf(\"unexpected EOF\")\n}\n\n// Err generates a custom parse-time error with a message of msg.\nfunc (d *Dispenser) Err(msg string) error {\n\treturn d.WrapErr(errors.New(msg))\n}\n\n// Errf is like Err, but for formatted error messages\nfunc (d *Dispenser) Errf(format string, args ...any) error {\n\treturn d.WrapErr(fmt.Errorf(format, args...))\n}\n\n// WrapErr takes an existing error and adds the Caddyfile file and line number.\nfunc (d *Dispenser) WrapErr(err error) error {\n\tif len(d.Token().imports) > 0 {\n\t\treturn fmt.Errorf(\"%w, at %s:%d import chain ['%s']\", err, d.File(), d.Line(), strings.Join(d.Token().imports, \"','\"))\n\t}\n\treturn fmt.Errorf(\"%w, at %s:%d\", err, d.File(), d.Line())\n}\n\n// Delete deletes the current token and returns the updated slice\n// of tokens. The cursor is not advanced to the next token.\n// Because deletion modifies the underlying slice, this method\n// should only be called if you have access to the original slice\n// of tokens and/or are using the slice of tokens outside this\n// Dispenser instance. If you do not re-assign the slice with the\n// return value of this method, inconsistencies in the token\n// array will become apparent (or worse, hide from you like they\n// did me for 3 and a half freaking hours late one night).\nfunc (d *Dispenser) Delete() []Token {\n\tif d.cursor >= 0 && d.cursor <= len(d.tokens)-1 {\n\t\td.tokens = append(d.tokens[:d.cursor], d.tokens[d.cursor+1:]...)\n\t\td.cursor--\n\t}\n\treturn d.tokens\n}","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/caddyconfig/caddyfile/dispenser.go#L429-L465","documentation":"The plain variant of Dispenser.WrapErr: decorates a Caddyfile error with the current token's file and line when the token did NOT come from an import. This is the standard 'parse error at Caddyfile:N' formatter used by all directive parsing.","triggerScenarios":"Any d.Err/d.Errf/d.WrapErr call on a token parsed directly from the top-level Caddyfile (empty imports list): unknown subdirective, wrong argument count, invalid value, etc.","commonSituations":"Typos in directives, missing required arguments, or Caddyfile syntax valid in an older Caddy version but no longer accepted. The reported line points at the offending token.","solutions":["Go to Caddyfile at the reported line and fix the directive described in the error text","Check the directive's docs for required arguments and subdirectives","Run `caddy adapt --config Caddyfile` to reproduce quickly without starting the server","If the syntax looks right, confirm your Caddy version supports the directive"],"exampleFix":"# before\nrespond \"hi\" \"extra-arg\"\n# after\nrespond \"hi\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := caddyfileUnmarshal(d); err != nil {\n    // WrapErr already embeds file:line; return it unchanged up the stack\n    return fmt.Errorf(\"caddyfile parse failed: %w\", err)\n}","preventionTips":["Adapt (`caddy adapt --config`) before validate/start","Match directive spelling against docs for your Caddy version","Enable editor Caddyfile syntax highlighting to catch typos"],"tags":["caddyfile","parse-error","diagnostics"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}