{"id":"55fc269fb4ea55e8","repo":"gohugoio/hugo","slug":"errhelp","errorCode":"errHelp","errorMessage":"help requested","messagePattern":"help requested","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"commands/commandeer.go","lineNumber":58,"sourceCode":"\t\"github.com/gohugoio/hugo/common/hstrings\"\n\t\"github.com/gohugoio/hugo/common/htime\"\n\t\"github.com/gohugoio/hugo/common/hugo\"\n\t\"github.com/gohugoio/hugo/common/loggers\"\n\t\"github.com/gohugoio/hugo/common/paths\"\n\t\"github.com/gohugoio/hugo/common/types\"\n\t\"github.com/gohugoio/hugo/config\"\n\t\"github.com/gohugoio/hugo/config/allconfig\"\n\t\"github.com/gohugoio/hugo/deps\"\n\t\"github.com/gohugoio/hugo/helpers\"\n\t\"github.com/gohugoio/hugo/hugofs\"\n\t\"github.com/gohugoio/hugo/hugolib\"\n\t\"github.com/gohugoio/hugo/identity\"\n\t\"github.com/gohugoio/hugo/resources/kinds\"\n\t\"github.com/spf13/afero\"\n\t\"github.com/spf13/cobra\"\n)\n\nvar errHelp = errors.New(\"help requested\")\n\n// Execute executes a command.\nfunc Execute(args []string) error {\n\t// Default GOMAXPROCS to be CPU limit aware, still respecting GOMAXPROCS env.\n\tmaxprocs.Set()\n\tx, err := newExec()\n\tif err != nil {\n\t\treturn err\n\t}\n\targs = mapLegacyArgs(args)\n\tcd, err := x.Execute(context.Background(), args)\n\tif cd != nil {\n\t\tif closer, ok := cd.Root.Command.(types.Closer); ok {\n\t\t\tcloser.Close()\n\t\t}\n\t}\n\n\tif err != nil {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/commandeer.go#L40-L76","documentation":"`errHelp` is a sentinel error (`errors.New(\"help requested\")`) used internally by Hugo's command layer (simplecobra wiring in `commandeer.go`) to signal that the user asked for help (`-h`/`--help` or bare invocation). It is not a real failure — callers compare against it to print usage and exit with success instead of reporting an error.","triggerScenarios":"Running `hugo --help`, `hugo <subcommand> -h`, or a command form that cobra resolves to a help request; the execution path returns `errHelp` up the stack where `Execute` intercepts it.","commonSituations":"Only visible to developers embedding or extending Hugo's `commands` package who propagate the error without checking `errors.Is(err, errHelp)`; end users never see this text in normal operation.","solutions":["If you see this surfaced as an error, check the call site for a missing `errors.Is(err, errHelp)` guard and treat it as a clean exit.","When embedding the commands package, filter this sentinel before logging errors from Execute."],"exampleFix":"// before\nif err := commands.Execute(args); err != nil { log.Fatal(err) }\n// after\nif err := commands.Execute(args); err != nil && !errors.Is(err, errHelp) { log.Fatal(err) }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// errHelp is a sentinel meaning --help was shown; not a real failure\nif errors.Is(err, errHelp) {\n    os.Exit(0)\n}","tryCatchPattern":"err := commandeer.Execute(args)\nswitch {\ncase err == nil:\ncase errors.Is(err, errHelp):\n    // help text already printed; exit success\ndefault:\n    log.Fatal(err)\n}","preventionTips":["Treat the help sentinel as a success path, never log it as an error","Compare with errors.Is against the sentinel rather than matching the message string","Keep exit-code mapping in one place so help never returns non-zero"],"tags":["hugo","cli","sentinel-error","cobra"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}