{"record":{"id":"a04ccc26f11c0ef6","repo":"AdguardTeam/AdGuardHome","slug":"action-q-w","errorCode":null,"errorMessage":"action %q: %w","messagePattern":"action %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/service.go","lineNumber":222,"sourceCode":"\t\t\tworkDir:         workDir,\n\t\t\tconfPath:        confPath,\n\t\t\tpidFilePath:     pidFilePath,\n\t\t\thostsContainer:  hc,\n\t\t}\n\n\t\treturn p.handleRun(ctx, baseLogger, runOpts)\n\t}\n\n\tswitch actionName {\n\tcase \"reload\":\n\t\terr = handleServiceReloadCmd(ctx, l, svcMgr)\n\tcase \"status\":\n\t\terr = handleServiceStatusCmd(ctx, l, svcMgr)\n\tdefault:\n\t\terr = handleServiceCommand(ctx, baseLogger, svcMgr, opts, workDir, confPath)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"action %q: %w\", actionName, err)\n\t}\n\n\treturn nil\n}\n\n// handleServiceCommand handles service command.\nfunc handleServiceCommand(\n\tctx context.Context,\n\tl *slog.Logger,\n\tmgr ossvc.Manager,\n\topts options,\n\tworkDir string,\n\tconfPath string,\n) (err error) {\n\tvar action ossvc.Action\n\tswitch opts.serviceControlAction {\n\tcase \"install\":\n\t\treturn handleServiceInstallCmd(ctx, l, mgr, opts, workDir, confPath)","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/service.go#L204-L240","documentation":"A service control action selected in handleServiceControlAction (install, uninstall, start, stop, restart, status, run) returned an error, which is wrapped with the action name for context.","triggerScenarios":"Any ./AdGuardHome -s <action> whose underlying handler fails — permission denied on install, unit-not-loaded on start/stop, or the 'run' path hitting cwd/service-init errors.","commonSituations":"Running control actions without root, operating on a service that isn't installed, or systemd refusing operations inside containers.","solutions":["Read the inner error — it carries the action-specific cause","Run with sudo for install/uninstall/start/stop/restart","Confirm the service is installed first: ./AdGuardHome -s status"],"exampleFix":"# before\n./AdGuardHome -s install\n\n# after\nsudo ./AdGuardHome -s install","handlingStrategy":"try-catch","validationCode":"// Verify action and service presence before performing:\nif !slices.Contains([]string{\"install\",\"uninstall\",\"start\",\"stop\",\"restart\",\"status\"}, action) {\n    return errors.New(\"unknown action\")\n}","typeGuard":null,"tryCatchPattern":"if err := handleServiceControlAction(...); err != nil {\n    // err wraps action-specific cause; branch on inner error for user guidance\n    log.Fatalf(\"%v\", err)\n}","preventionTips":["Run control actions with appropriate privileges","Check status before start/stop/restart"],"tags":["go","service","cli","systemd","privileges"],"backgroundTag":"service-action-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}