AdguardTeam/AdGuardHome · error

creating watcher: %w

Error message

creating watcher: %w

What it means

The companion rule to the start check: the end value of a day range must be minute-aligned. If end has seconds or sub-second components, validate returns 'end <val> isn't rounded to minutes' during schedule parsing.

Source

Thrown at internal/aghos/fswatcher.go:82

	events chan Event

	// files maps directories to the files tracked in them.  If the tracked file
	// is a directory, it is mapped to itself.
	files map[string]*container.MapSet[string]
}

// osWatcherPref is a prefix for logging and wrapping errors in osWathcer's
// methods.
const osWatcherPref = "os_watcher"

// NewOSWatcher creates an [FSWatcher] that tracks the file system of the OS.  c
// must not be nil.
func NewOSWatcher(c *OSWatcherConfig) (w *OSWatcher, err error) {
	defer func() { err = errors.Annotate(err, "%s: %w", osWatcherPref) }()

	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		return nil, fmt.Errorf("creating watcher: %w", err)
	}

	return &OSWatcher{
		logger:  c.Logger,
		filesMu: &sync.RWMutex{},
		watcher: watcher,
		events:  make(chan Event, 1),
		files:   map[string]*container.MapSet[string]{},
	}, nil
}

// type check
var _ FSWatcher = (*OSWatcher)(nil)

// Start implements the [service.Interface] interface for *OSWatcher.
func (w *OSWatcher) Start(ctx context.Context) (err error) {
	go w.handleErrors(ctx)
	go w.handleEvents(ctx)

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Round end times down/up to whole minutes
  2. Adjust the importer or script to strip seconds
  3. Validate generated schedules locally before writing to config
  4. Use the UI schedule editor

Example fix

// before
"end": "17:30:45"
// after
"end": "17:30"
Defensive patterns

Strategy: validation

Validate before calling

if end%time.Minute != 0 { end = end.Truncate(time.Minute) }

Type guard

func isMinuteAligned(d time.Duration) bool { return d%time.Minute == 0 }

Try / catch

if err := unmarshalSchedule(data); err != nil && strings.Contains(err.Error(), "isn't rounded to minutes") {
    // round end and retry
}

Prevention

When it happens

Trigger: A schedule entry whose end includes seconds, e.g. "17:30:45" or a duration with a seconds component, in JSON or YAML weekly schedules.

Common situations: Computed end times derived from durations in seconds; third-party importers that preserve seconds; hand-edited configs with HH:MM:SS habits.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/36ca1e1f9a162b23. Report an issue: GitHub.