{"record":{"id":"da731ebb81c04768","repo":"AdguardTeam/AdGuardHome","slug":"service-manager-can-t-reload-w","errorCode":null,"errorMessage":"service manager can't reload: %w","messagePattern":"service manager can't reload: %w","errorType":"exception","errorClass":"errors.ErrUnsupported","httpStatus":null,"severity":"error","filePath":"internal/home/service.go","lineNumber":292,"sourceCode":"\tcase ossvc.StatusNotInstalled:\n\t\tl.InfoContext(ctx, \"not installed\")\n\tcase ossvc.StatusStopped:\n\t\tl.InfoContext(ctx, \"stopped\")\n\tcase ossvc.StatusRunning:\n\t\tl.InfoContext(ctx, \"running\")\n\tcase ossvc.StatusRestartOnFail:\n\t\tl.InfoContext(ctx, \"restarting after failed start\")\n\t}\n\n\treturn nil\n}\n\n// handleServiceReloadCmd reloads the service, if it's running.  l must not be\n// nil, mgr must be a ReloadManager.\nfunc handleServiceReloadCmd(ctx context.Context, l *slog.Logger, mgr ossvc.Manager) (err error) {\n\trelSvcMgr, ok := mgr.(ossvc.ReloadManager)\n\tif !ok {\n\t\treturn fmt.Errorf(\"service manager can't reload: %w\", errors.ErrUnsupported)\n\t}\n\n\terr = relSvcMgr.Reload(ctx, serviceName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reloading service: %w\", err)\n\t}\n\n\tl.InfoContext(ctx, \"service reloaded successfully\")\n\n\treturn nil\n}\n\n// handleServiceInstallCmd handles the service \"install\" command.  l must\n// not be nil.\nfunc handleServiceInstallCmd(\n\tctx context.Context,\n\tl *slog.Logger,\n\tmgr ossvc.Manager,","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/service.go#L274-L310","documentation":"Thrown when the user runs the 'reload' service control action but the platform's service manager does not implement the ossvc.ReloadManager interface. The code performs a type assertion on the Manager; on platforms whose manager has no Reload method (or when a mock/unsupported implementation is injected), the assertion fails and the error wraps errors.ErrUnsupported.","triggerScenarios":"Invoking the service command with action=reload on an OS whose ossvc.Manager implementation does not also implement ReloadManager (e.g. a minimal or third-party manager implementation), or unit tests passing a plain Manager mock.","commonSituations":"Running 'AdGuardHome -s reload' on an OS without a reload-capable service integration; custom builds that swap in their own ossvc.Manager; version changes where ReloadManager was newly required but the implementation wasn't updated.","solutions":["Use a different action (e.g. 'restart' or 'stop'/'start') which all managers support","If you maintain a custom Manager, implement Reload(ctx, serviceName) error so it satisfies ossvc.ReloadManager","Check errors.Is(err, errors.ErrUnsupported) to detect this case and fall back to restart"],"exampleFix":"// before\nrelSvcMgr, ok := mgr.(ossvc.ReloadManager)\nif !ok {\n\treturn fmt.Errorf(\"service manager can't reload: %w\", errors.ErrUnsupported)\n}\n\n// after (caller fallback)\nerr := handleServiceControlAction(ctx, l, mgr, \"reload\")\nif errors.Is(err, errors.ErrUnsupported) {\n\terr = handleServiceControlAction(ctx, l, mgr, \"restart\")\n}","handlingStrategy":"fallback","validationCode":"// before invoking the action\nif _, ok := mgr.(ossvc.ReloadManager); !ok {\n    // choose restart instead of reload\n}","typeGuard":"func canReload(mgr ossvc.Manager) bool {\n    _, ok := mgr.(ossvc.ReloadManager)\n    return ok\n}","tryCatchPattern":"// after\ncallErr := handleServiceControlAction(ctx, l, mgr, \"reload\")\nif errors.Is(callErr, errors.ErrUnsupported) {\n    callErr = handleServiceControlAction(ctx, l, mgr, \"restart\")\n}","preventionTips":["Check manager capabilities before choosing the reload action","Prefer 'restart' in cross-platform automation","Detect errors.ErrUnsupported to branch instead of failing"],"tags":["service-management","unsupported-operation","type-assertion"],"backgroundTag":"unsupported-platform-operation","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}