{"record":{"id":"c7d0e66104ac91a5","repo":"caddyserver/caddy","slug":"s-d-caddyfile-input-is-not-formatted-tip-use","errorCode":null,"errorMessage":"%s:%d: Caddyfile input is not formatted; Tip: use '--overwrite' to update your Caddyfile in-place instead of previewing it. Consult '--help' for more options","messagePattern":"(.+?):(.+?): Caddyfile input is not formatted; Tip: use '--overwrite' to update your Caddyfile in-place instead of previewing it\\. Consult '--help' for more options","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/commandfuncs.go","lineNumber":741,"sourceCode":"\t\tdiff := difflib.Diff(\n\t\t\tstrings.Split(string(input), \"\\n\"),\n\t\t\tstrings.Split(string(output), \"\\n\"))\n\t\tfor _, d := range diff {\n\t\t\tswitch d.Delta {\n\t\t\tcase difflib.Common:\n\t\t\t\tfmt.Printf(\"  %s\\n\", d.Payload)\n\t\t\tcase difflib.LeftOnly:\n\t\t\t\tfmt.Printf(\"- %s\\n\", d.Payload)\n\t\t\tcase difflib.RightOnly:\n\t\t\t\tfmt.Printf(\"+ %s\\n\", d.Payload)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfmt.Print(string(output))\n\t}\n\n\tif warning, diff := caddyfile.FormattingDifference(configFile, input); diff {\n\t\treturn caddy.ExitCodeFailedStartup, fmt.Errorf(`%s:%d: Caddyfile input is not formatted; Tip: use '--overwrite' to update your Caddyfile in-place instead of previewing it. Consult '--help' for more options`,\n\t\t\twarning.File,\n\t\t\twarning.Line,\n\t\t)\n\t}\n\n\treturn caddy.ExitCodeSuccess, nil\n}\n\n// handleEnvFileFlag loads the environment variables from the given --envfile\n// flag if specified. This should be called as early in the command function.\nfunc handleEnvFileFlag(fl Flags) error {\n\tvar err error\n\tvar envfileFlag []string\n\tenvfileFlag, err = fl.GetStringSlice(\"envfile\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading envfile flag: %v\", err)\n\t}\n","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/cmd/commandfuncs.go#L723-L759","documentation":"Error \"%s:%d: Caddyfile input is not formatted; Tip: use '--overwrite' to update your Caddyfile in-place instead of previewing it. Consult '--help' for more options\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at cmd/commandfuncs.go:741 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run 'caddy fmt --overwrite' to format the file in place, or apply the shown formatting changes manually."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}