{"record":{"id":"ad00a9f8e303d1f4","repo":"netbirdio/netbird","slug":"save-service-params-w","errorCode":null,"errorMessage":"save service params: %w","messagePattern":"save service params: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/cmd/service_params.go","lineNumber":70,"sourceCode":"\t\t\treturn nil, nil //nolint:nilnil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"read service params %s: %w\", path, err)\n\t}\n\n\tvar params serviceParams\n\tif err := json.Unmarshal(data, &params); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse service params %s: %w\", path, err)\n\t}\n\n\treturn &params, nil\n}\n\n// saveServiceParams writes current service parameters to disk atomically\n// with restricted permissions.\nfunc saveServiceParams(params *serviceParams) error {\n\tpath := serviceParamsPath()\n\tif err := util.WriteJsonWithRestrictedPermission(context.Background(), path, params); err != nil {\n\t\treturn fmt.Errorf(\"save service params: %w\", err)\n\t}\n\treturn nil\n}\n\n// currentServiceParams captures the current state of all package-level\n// variables into a serviceParams struct.\nfunc currentServiceParams() *serviceParams {\n\tparams := &serviceParams{\n\t\tLogLevel:              logLevel,\n\t\tDaemonAddr:            daemonAddr,\n\t\tJSONSocket:            jsonSocket,\n\t\tManagementURL:         managementURL,\n\t\tConfigPath:            configPath,\n\t\tLogFiles:              logFiles,\n\t\tDisableProfiles:       profilesDisabled,\n\t\tDisableUpdateSettings: updateSettingsDisabled,\n\t\tEnableCapture:         captureEnabled,\n\t\tDisableNetworks:       networksDisabled,","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/service_params.go#L52-L88","documentation":"saveServiceParams could not persist install parameters. WriteJsonWithRestrictedPermission creates the parent directory, enforces restrictive permissions, then writes via temp file plus rename; the wrap carries whichever step failed. CLI callers only print a warning, so the service itself is usually still installed.","triggerScenarios":"State directory not writable (non-root run after root owned /var/lib/netbird); the permission-enforcement chmod failing; rename blocked by the filesystem; disk full.","commonSituations":"Running install/reconfigure with partial privileges; read-only or network-mounted state dirs; Windows ACL inheritance blocking the permission step.","solutions":["Run install/reinstall elevated so the state dir is writable","Fix the state dir: sudo mkdir -p /var/lib/netbird && sudo chown root:root /var/lib/netbird","Free disk space and remount read-only mounts read-write","Retry the save via a reconfigure once the directory is fixed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"dir := filepath.Dir(serviceParamsPath())\nif err := os.MkdirAll(dir, 0o750); err != nil {\n\treturn fmt.Errorf(\"state dir %s not writable: %w\", dir, err)\n}\nif f, err := os.CreateTemp(dir, \".probe\"); err != nil {\n\treturn fmt.Errorf(\"state dir %s not writable: %w\", dir, err)\n} else {\n\t_ = f.Close()\n\t_ = os.Remove(f.Name())\n}","typeGuard":null,"tryCatchPattern":"if err := saveServiceParams(currentServiceParams()); err != nil {\n\t// callers only warn: the install itself succeeded\n\tcmd.PrintErrf(\"Warning: failed to save service params: %v\\n\", err)\n}","preventionTips":["Install with elevation so the state dir is writable","Verify /var/lib/netbird ownership once after provisioning","Treat repeated save failures as a state-dir permission defect"],"tags":["service","state","file-permissions","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}