AdguardTeam/AdGuardHome · error

removing %q: %w

Error message

removing %q: %w

What it means

dayRange.validate requires start to be strictly earlier than end; an inverted or zero-length range yields 'start <s> is greater or equal to end <e>'. This catches reversed times and empty intervals during JSON/YAML schedule parsing.

Source

Thrown at internal/aghos/fswatcher.go:188

	}

	if !names.Has(name) {
		// Name is not tracked.
		return nil
	}

	names.Delete(name)
	if names.Len() > 0 {
		// Some files are still tracked in the directory.
		return nil
	}

	// No more files tracked in the directory, unwatch it.
	delete(w.files, dirName)

	err = w.watcher.Remove(dirName)
	if err != nil {
		return fmt.Errorf("removing %q: %w", dirName, err)
	}

	return nil
}

// handleEvents notifies about the received file system's event if needed.  It
// is intended to be used as a goroutine.
func (w *OSWatcher) handleEvents(ctx context.Context) {
	defer slogutil.RecoverAndLog(ctx, w.logger)

	defer close(w.events)

	ch := w.watcher.Events
	for e := range ch {
		if !w.isTrackedEvent(e) {
			continue
		}

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Split overnight ranges into two entries: one ending at 24:00 and one starting at 00:00
  2. Swap start/end if they are merely reversed
  3. Ensure start < end strictly (equal values are rejected)
  4. Model full-day as start 00:00 end 24:00 (maxDayRange) if supported

Example fix

// before
{"start": "22:00", "end": "06:00"}
// after
{"sun": {"start": "00:00", "end": "06:00"},
 "sat": {"start": "22:00", "end": "24:00"}}
Defensive patterns

Strategy: validation

Validate before calling

if start >= end { return fmt.Errorf("inverted range %v-%v", start, end) }

Type guard

func isValidOrder(s, e time.Duration) bool { return s < e }

Try / catch

if err := unmarshalSchedule(data); err != nil && strings.Contains(err.Error(), "greater or equal to end") {
    // swap or split overnight range, retry
}

Prevention

When it happens

Trigger: A schedule day where start equals end or start is after end, e.g. start "22:00" end "06:00" (attempting overnight ranges, which the schema forbids) or start == end.

Common situations: Users trying to express overnight schedules crossing midnight; swapped start/end in hand-edited configs; importers mapping 'from/to' fields in the wrong order.

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/45cf1e88e9a6deff. Report an issue: GitHub.