AdguardTeam/AdGuardHome · error

generating config file

Error message

generating config file: %w

What it means

Writing the config file object failed at the YAML encoding stage: yaml.Encoder could not serialize the configuration into bytes. Encoding errors usually reflect unmarshalable or incompatible field types after schema changes.

Solutions

  1. Check the wrapped error for the offending field
  2. Recreate the config from a known-good backup instead of the corrupted state
  3. Upgrade to a consistent AdGuard Home version (avoid mixing binaries and data from different releases)
Defensive patterns

Strategy: fallback

Try / catch

// Fall back to last known-good config file
if err := persistConfig(cfg); err != nil { cfg = loadBackup() }

Prevention

When it happens

Trigger: Persisting config (e.g. after a setup/PUT /control/config or internal update) where some field of the config struct cannot be marshaled to YAML.

Common situations: Version mismatches or corrupted in-memory config after partial upgrades; exotic custom types injected by plugins; extremely rare in stock builds.

Related errors


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

Appendix: source

Thrown at internal/home/config.go:917

		dns.UpstreamTimeout = timeutil.Duration(s.UpstreamTimeout())
	}

	if globalContext.dhcpServer != nil {
		globalContext.dhcpServer.WriteDiskConfig(config.DHCP)
	}

	config.Clients.Persistent = globalContext.clients.forConfig()

	confPath = configFilePath(ctx, l, workDir, confPath)
	l.DebugContext(ctx, "writing config file", "path", confPath)

	buf := &bytes.Buffer{}
	enc := yaml.NewEncoder(buf)
	enc.SetIndent(2)

	err = enc.Encode(config)
	if err != nil {
		return fmt.Errorf("generating config file: %w", err)
	}

	err = maybe.WriteFile(confPath, buf.Bytes(), aghos.DefaultPermFile)
	if err != nil {
		return fmt.Errorf("writing config file: %w", err)
	}

	return nil
}

// validateTLSCipherIDs validates the custom TLS cipher suite IDs.
func validateTLSCipherIDs(cipherIDs []string) (err error) {
	if len(cipherIDs) == 0 {
		return nil
	}

	_, err = aghtls.ParseCiphers(cipherIDs)
	if err != nil {

View on GitHub (pinned to b41aefbe51)