AdguardTeam/AdGuardHome · error · errors.ErrBadEnumValue

%w: %q

Error message

%w: %q

What it means

handleServiceCommand received a serviceControlAction that isn't one of the known verbs (start/stop/restart), so the action variable can't be constructed and errors.ErrBadEnumValue is wrapped with the offending value.

Source

Thrown at internal/home/service.go:258

		return handleServiceInstallCmd(ctx, l, mgr, opts, workDir, confPath)
	case "uninstall":
		action = &ossvc.ActionUninstall{
			ServiceName: serviceName,
		}
	case "start":
		action = &ossvc.ActionStart{
			ServiceName: serviceName,
		}
	case "stop":
		action = &ossvc.ActionStop{
			ServiceName: serviceName,
		}
	case "restart":
		action = &ossvc.ActionRestart{
			ServiceName: serviceName,
		}
	default:
		return fmt.Errorf("%w: %q", errors.ErrBadEnumValue, opts.serviceControlAction)
	}

	return mgr.Perform(ctx, action)
}

// handleServiceStatusCmd logs the service's status.  l and mgr must not be
// nil.
func handleServiceStatusCmd(ctx context.Context, l *slog.Logger, mgr ossvc.Manager) (err error) {
	status, err := mgr.Status(ctx, serviceName)
	if err != nil {
		// Don't wrap the error, since it's informative enough as is.
		return err
	}

	switch status {
	case ossvc.StatusNotInstalled:
		l.InfoContext(ctx, "not installed")
	case ossvc.StatusStopped:

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Use only: start, stop, restart (status is handled elsewhere but also valid via -s status)
  2. Check spelling of the action verb
  3. Run ./AdGuardHome --help to see the supported -s values

Example fix

# before
./AdGuardHome -s reload

# after
./AdGuardHome -s restart
Defensive patterns

Strategy: validation

Validate before calling

var validActions = map[string]bool{"start":true,"stop":true,"restart":true}
if !validActions[opts.serviceControlAction] {
    return fmt.Errorf("unsupported action %q; use start|stop|restart", opts.serviceControlAction)
}

Type guard

func isServiceCommand(s string) bool {
    switch s { case "start", "stop", "restart": return true }; return false
}

Prevention

When it happens

Trigger: Passing an unrecognized subcommand to -s, e.g. ./AdGuardHome -s reload or -s pause; the string falls through the switch's default case.

Common situations: Users assuming actions like 'reload' or 'status' route through this handler, typos, or scripts written against different service CLIs (nginx -s reload style muscle memory).

Related errors


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