{"record":{"id":"8023c10c94b8ffec","repo":"gohugoio/hugo","slug":"invalid-value-for-flag-poll-s","errorCode":null,"errorMessage":"invalid value for flag poll: %s","messagePattern":"invalid value for flag poll: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/hugobuilder.go","lineNumber":322,"sourceCode":"\t\treturn nil, fmt.Errorf(\"failed to start trace: %w\", err)\n\t}\n\n\treturn func() {\n\t\ttrace.Stop()\n\t\tf.Close()\n\t}, nil\n}\n\n// newWatcher creates a new watcher to watch filesystem events.\nfunc (c *hugoBuilder) newWatcher(pollIntervalStr string, dirList ...string) (*watcher.Batcher, error) {\n\tstaticSyncer := &staticSyncer{c: c}\n\n\tvar pollInterval time.Duration\n\tpoll := pollIntervalStr != \"\"\n\tif poll {\n\t\tpollInterval, err := types.ToDurationE(pollIntervalStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid value for flag poll: %s\", err)\n\t\t}\n\t\tc.r.logger.Printf(\"Use watcher with poll interval %v\", pollInterval)\n\t}\n\n\tif pollInterval == 0 {\n\t\tpollInterval = 500 * time.Millisecond\n\t}\n\n\twatcher, err := watcher.New(500*time.Millisecond, pollInterval, poll)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\th, err := c.hugo()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tspec := h.Deps.SourceSpec","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/hugobuilder.go#L304-L340","documentation":"`hugoBuilder.newWatcher` parses the `--poll` flag string with `types.ToDurationE` into a `time.Duration`. This error wraps the parse failure, meaning the supplied string is not a value Go's `time.ParseDuration` can interpret.","triggerScenarios":"Fires only when `pollIntervalStr != \"\"` and `types.ToDurationE` errors — e.g. `--poll=500`, `--poll=fast`, or any value missing a unit or using an unsupported suffix.","commonSituations":"Passing a bare number like `--poll=250` (Go durations require a unit such as `ms`, `s`); using `--poll=250ms` works while `--poll=0.25s` works too; typos like `--poll=250msec`.","solutions":["Supply a unit-suffixed duration, e.g. `--poll=250ms` or `--poll=2s`.","Omit `--poll` to use the default fsnotify watcher (polling disabled).","Check the exact flag value in your script/CI env for stray characters."],"exampleFix":"// before\n// $ hugo server --poll=500\n// after\n// $ hugo server --poll=500ms","handlingStrategy":"validation","validationCode":"// Validate the --poll string the same way Hugo will.\nimport \"time\"\nfunc validatePollFlag(s string) error {\n  if s == \"\" { return nil }\n  _, err := time.ParseDuration(s)\n  return err\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always suffix `--poll` with a Go duration unit (`ms`, `s`).","Validate the value in your wrapper script before invoking `hugo server`.","Leave `--poll` unset to use the default fsnotify watcher."],"tags":["hugo","watcher","configuration","go"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}