{"record":{"id":"0040e475f30eff03","repo":"babalae/better-genshin-impact","slug":"url","errorCode":null,"errorMessage":"URL不能为空","messagePattern":"URL不能为空","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"warning","filePath":"BetterGenshinImpact/Core/Script/Dependence/HtmlMask.cs","lineNumber":80,"sourceCode":"    private readonly object _openedWindowsLock = new();\n    private bool _disposed;\n\n    public HtmlMask(string workDir)\n    {\n        _workDir = workDir;\n    }\n\n    #region 窗口管理\n\n    /// <summary>\n    /// 显示HTML遮罩窗口\n    /// </summary>\n    public string Show(string url, string? id = null)\n    {\n        try\n        {\n            if (string.IsNullOrWhiteSpace(url))\n                throw new ArgumentException(\"URL不能为空\");\n\n            string finalUrl;\n\n            if (url.StartsWith(\"http\", StringComparison.OrdinalIgnoreCase))\n            {\n                finalUrl = url;\n            }\n            else\n            {\n                // 禁止 file:// 绝对路径，仅允许脚本目录下的相对路径\n                string absPath = ScriptUtils.NormalizePath(_workDir, url);\n                finalUrl = new Uri(absPath).AbsoluteUri;\n            }\n\n            string windowId = HtmlMaskWindow.Show(finalUrl, id, _workDir);\n\n            _toHtmlQueues[windowId] = new ConcurrentQueue<Message>();\n            _fromHtmlQueues[windowId] = new ConcurrentQueue<Message>();","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Dependence/HtmlMask.cs#L62-L98","documentation":"Thrown by HtmlMask.Show when the url parameter is null, empty, or consists only of whitespace. The Show method is the entry point for displaying an HTML overlay window; it requires either an http(s) URL or a file path relative to the script's working directory.","triggerScenarios":"Calling htmlMask.Show(url) where url is null, \"\", or \"   \". This can happen when a script reads a URL from config and the config key is missing or empty.","commonSituations":"Script reads an HTML file path from a JSON manifest but the key is absent, producing null. Dynamic URL construction results in an empty string due to a missing template variable. Pass-through from an unvalidated user input field.","solutions":["Check string.IsNullOrWhiteSpace(url) before calling Show and provide a default or error message.","Validate the config source: ensure the URL/path key exists and is non-empty.","Log the resolved URL at debug level to catch empty values early."],"exampleFix":"// before\nhtmlMask.Show(config[\"overlayUrl\"]);\n\n// after\nvar url = config[\"overlayUrl\"];\nif (string.IsNullOrWhiteSpace(url))\n    throw new ArgumentException(\"overlayUrl must be specified in config\");\nhtmlMask.Show(url);","handlingStrategy":"validation","validationCode":"// Validate URL before calling Show\nif (string.IsNullOrWhiteSpace(url))\n    throw new ArgumentException(\"URL cannot be null or empty\", nameof(url));\nhtmlMask.Show(url, windowId);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check string.IsNullOrWhiteSpace(url) before calling Show.","Validate config-sourced URLs at script initialization.","Provide meaningful defaults or error messages for missing URL config."],"tags":["validation","html-mask","url","argument","precondition"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}