{"record":{"id":"e8b3b5026c80d97e","repo":"2dust/v2rayN","slug":"webdav-parameter-error-or-null","errorCode":null,"errorMessage":"webdav parameter error or null","messagePattern":"webdav parameter error or null","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"v2rayN/ServiceLib/Manager/WebDavManager.cs","lineNumber":30,"sourceCode":"    private string? _lastDescription;\n    private string _webDir = Global.AppName + \"_backup\";\n    private readonly string _webFileName = \"backup.zip\";\n    private readonly string _tag = \"WebDav--\";\n\n    public WebDavManager()\n    {\n        _config = AppManager.Instance.Config;\n    }\n\n    private async Task<bool> GetClient()\n    {\n        try\n        {\n            if (_config.WebDavItem.Url.IsNullOrEmpty()\n            || _config.WebDavItem.UserName.IsNullOrEmpty()\n            || _config.WebDavItem.Password.IsNullOrEmpty())\n            {\n                throw new ArgumentException(\"webdav parameter error or null\");\n            }\n            if (_client != null)\n            {\n                _client?.Dispose();\n                _client = null;\n            }\n            if (_config.WebDavItem.DirName.IsNullOrEmpty())\n            {\n                _webDir = Global.AppName + \"_backup\";\n            }\n            else\n            {\n                _webDir = _config.WebDavItem.DirName.TrimEx();\n            }\n\n            // Ensure BaseAddress URL ends with a trailing slash\n            var baseUrl = _config.WebDavItem.Url.Trim().TrimEnd('/') + \"/\";\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/2dust/v2rayN/blob/e01717d8326a4f5060b335523590c5fda943fe03/v2rayN/ServiceLib/Manager/WebDavManager.cs#L12-L48","documentation":"Thrown by WebDavManager.GetClient when any of WebDavItem.Url, UserName, or Password is null or empty. These three are required to construct the WebDAV client, so the manager refuses to proceed.","triggerScenarios":"GetClient checks _config.WebDavItem; if Url, UserName, or Password is null/empty (IsNullOrEmpty true), it throws ArgumentException before building the client.","commonSituations":"WebDAV backup was never configured; user saved partial settings (URL but no credentials); password field cleared; config migration/reset left WebDavItem default; credentials stored in a different field by mistake.","solutions":["Open WebDAV settings and fill in URL, UserName, and Password completely.","Validate the three fields in the settings UI before enabling WebDAV backup (show a validation error instead of letting GetClient throw).","Confirm the URL includes the scheme and full WebDAV path (e.g. https://host/dav/).","If migrating configs, ensure WebDavItem is populated (default values are null/empty and will trip this)."],"exampleFix":"// before - throws deep in GetClient when settings are incomplete\nawait webDav.GetClient();\n\n// after - validate at the UI/call boundary\nvar w = _config.WebDavItem;\nif (w.Url.IsNullOrEmpty() || w.UserName.IsNullOrEmpty() || w.Password.IsNullOrEmpty())\n{\n    throw new InvalidOperationException(\"Configure WebDAV URL, username, and password before use.\");\n}","handlingStrategy":"validation","validationCode":"var w = _config.WebDavItem;\nif (string.IsNullOrEmpty(w?.Url) || string.IsNullOrEmpty(w.UserName) || string.IsNullOrEmpty(w.Password))\n    throw new InvalidOperationException(\"Configure WebDAV URL, username, and password before use.\");","typeGuard":"static bool IsWebDavConfigured(WebDavItem w) => w != null && !string.IsNullOrEmpty(w.Url) && !string.IsNullOrEmpty(w.UserName) && !string.IsNullOrEmpty(w.Password);","tryCatchPattern":"try\n{\n    await webDavManager.GetClient();\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"webdav parameter\"))\n{\n    // settings incomplete; prompt user to configure WebDAV credentials\n}","preventionTips":["Validate Url, UserName, and Password in the settings UI before enabling WebDAV backup.","Ensure the URL includes scheme and full WebDAV path.","After config migration/reset, confirm WebDavItem is populated."],"tags":["webdav","configuration","validation","backup"],"backgroundTag":null,"analyzedSha":"e01717d8326a4f5060b335523590c5fda943fe03","analyzedAt":"2026-08-13T10:10:23.416Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}