AdguardTeam/AdGuardHome · error

invalid pattern %q: %w

Error message

invalid pattern %q: %w

What it means

dayRange.validate requires time values to be whole minutes; if the start value loses information when truncated to a minute (i.e. it has seconds or sub-seconds), the error 'start <val> isn't rounded to minutes' is returned during schedule unmarshalling.

Source

Thrown at internal/aghos/filewalker.go:69

	return c(f)
}

// handlePatterns parses the patterns in fsys and ignores duplicates using
// srcSet.  srcSet must be non-nil.
func handlePatterns(
	fsys fs.FS,
	srcSet *container.MapSet[string],
	patterns ...string,
) (sub []string, err error) {
	sub = make([]string, 0, len(patterns))
	for _, p := range patterns {
		var matches []string
		matches, err = fs.Glob(fsys, p)
		if err != nil {
			// Enrich error with the pattern because filepath.Glob
			// doesn't do it.
			return nil, fmt.Errorf("invalid pattern %q: %w", p, err)
		}

		for _, m := range matches {
			if srcSet.Has(m) {
				continue
			}

			srcSet.Add(m)
			sub = append(sub, m)
		}
	}

	return sub, nil
}

// Walk starts walking the files in fsys defined by patterns from initial.
// It only returns true if fw signed to stop walking.
func (fw FileWalker) Walk(fsys fs.FS, initial ...string) (ok bool, err error) {

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Round start times to whole minutes in the schedule source
  2. Fix the generating script to emit minute-precision durations
  3. Use the built-in schedule editor, which enforces minute granularity
  4. Re-parse the config after fixing to confirm the error is gone

Example fix

// before
"start": "09:00:30"
// after
"start": "09:00"
Defensive patterns

Strategy: validation

Validate before calling

if start%time.Minute != 0 { start = start.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 start/end and retry
}

Prevention

When it happens

Trigger: A schedule entry whose start includes seconds/sub-second precision, e.g. "09:00:30" or a millisecond-based duration value, in JSON or YAML weekly schedules.

Common situations: Scripts computing start times from seconds-based timestamps; copying ISO 8601 durations with seconds (PT9H30M30S); UI versions or third-party tools emitting second precision.

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/5ee011b90f6e4160. Report an issue: GitHub.