AdguardTeam/AdGuardHome · error

writing conf: %w

Error message

writing conf: %w

What it means

Identical to the JSON case, but raised while unmarshalling the weekly schedule from YAML (UnmarshalYAML). Each weekday's range is validated; the first invalid day aborts parsing with 'weekday <Day>: <cause>'.

Source

Thrown at internal/aghnet/net_linux.go:185

	ifaceName string,
) (err error) {
	ipNet := GetSubnet(ctx, l, ifaceName)
	if !ipNet.Addr().IsValid() {
		return errors.Error("can't get IP address")
	}

	body, err := os.ReadFile(dhcpcdConf)
	if err != nil && !errors.Is(err, os.ErrNotExist) {
		return err
	}

	gatewayIP := GatewayIP(ctx, l, cmdCons, ifaceName)
	add := dhcpcdConfIface(ifaceName, ipNet, gatewayIP)

	body = append(body, []byte(add)...)
	err = maybe.WriteFile(dhcpcdConf, body, 0o644)
	if err != nil {
		return fmt.Errorf("writing conf: %w", err)
	}

	return nil
}

// dhcpcdConfIface returns configuration lines for the dhcpdc.conf files that
// configure the interface to have a static IP.
func dhcpcdConfIface(ifaceName string, subnet netip.Prefix, gateway netip.Addr) (conf string) {
	b := &strings.Builder{}
	stringutil.WriteToBuilder(
		b,
		"\n# ",
		ifaceName,
		" added by AdGuard Home.\ninterface ",
		ifaceName,
		"\nstatic ip_address=",
		subnet.String(),
		"\n",

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Check the named weekday and the wrapped validation cause
  2. Set start/end as non-negative minute-aligned durations (or HH:MM strings) with start < end within the same day
  3. Lint the YAML and use the UI's schedule editor when possible
  4. Add unit tests for schedule parsing in your config tooling

Example fix

# before
sat:
  start: -01:00
  end: 02:00:30
# after
sat:
  start: 01:00
  end: 02:00
Defensive patterns

Strategy: validation

Validate before calling

# Validate before writing YAML
# ensure start/end are non-negative, minute-aligned, start < end, end <= 24h

Type guard

func isValidDayRangeYAML(s, e string) bool {
    ds, e1 := time.ParseDuration(s)
    de, e2 := time.ParseDuration(e)
    return e1 == nil && e2 == nil && isValidDayRange(ds, de)
}

Try / catch

if err := yaml.Unmarshal(data, &sched); err != nil {
    if strings.HasPrefix(err.Error(), "weekday ") {
        // fix the named day in the YAML source
    }
}

Prevention

When it happens

Trigger: Loading a YAML config containing a weekly schedule where any day's start/end fails dayRange.validate (negative, start >= end, not minute-rounded, or exceeding the day).

Common situations: Editing the YAML config directly with invalid durations; using HH:MM:SS instead of minute precision; time-zone math producing negative durations; scheduler entries past 24:00.

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/84f34c34765e0e2f. Report an issue: GitHub.