{"record":{"id":"e8b325e28c1e6e2a","repo":"wtfutil/wtf","slug":"invalid-url-w","errorCode":null,"errorMessage":"invalid URL: %w","messagePattern":"invalid URL: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/uptimekuma/widget.go","lineNumber":222,"sourceCode":"\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tvar data HeartbeatData\n\tif err := json.NewDecoder(resp.Body).Decode(&data); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &data, nil\n}\n\nfunc parseURL(rawURL string) (string, string, error) {\n\tif rawURL == \"\" {\n\t\treturn \"\", \"\", fmt.Errorf(\"URL is not defined\")\n\t}\n\n\tu, err := url.Parse(rawURL)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"invalid URL: %w\", err)\n\t}\n\n\tparts := strings.Split(strings.Trim(u.Path, \"/\"), \"/\")\n\tif len(parts) < 2 || parts[0] != \"status\" {\n\t\treturn \"\", \"\", fmt.Errorf(\"invalid status page URL format. Expected '.../status/<slug>'\")\n\t}\n\n\tslug := parts[1]\n\tbaseURL := fmt.Sprintf(\"%s://%s\", u.Scheme, u.Host)\n\n\treturn baseURL, slug, nil\n}\n","sourceCodeStart":204,"sourceCodeEnd":235,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/uptimekuma/widget.go#L204-L235","documentation":"After the URL passes the empty check, parseURL calls url.Parse. 'invalid URL: %w' wraps any parsing error returned by net/url.Parse — meaning the configured string is not a syntactically valid absolute URL (bad scheme, control characters, malformed percent-encoding, etc.). The %w wrap preserves the underlying url.Parse error.","triggerScenarios":"Refresh calls parseURL with a configured URL string that url.Parse rejects — e.g. url: \"ht!tp://foo\", a URL containing spaces or unescaped special characters, or a garbage non-URL string.","commonSituations":"Typo'd scheme, pasting a URL with trailing spaces or invisible characters from documentation, missing scheme combined with characters url.Parse treats as invalid, quoting mistakes in YAML that inject stray characters.","solutions":["Inspect the wrapped cause after '%!' to see the exact url.Parse complaint and fix that character/portion of the URL","Ensure the URL includes a valid scheme and host, e.g. https://uptime.example.com/status/main","Quote the value in YAML (url: \"...\") to avoid special-character parsing issues, and trim whitespace"],"exampleFix":"// before\nurl: https://uptime.example.com/status/main \n// after\nurl: \"https://uptime.example.com/status/main\"","handlingStrategy":"validation","validationCode":"u, err := url.Parse(cfg.URL)\nif err != nil {\n    return fmt.Errorf(\"uptimekuma url invalid: %w\", err)\n}\nif u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"uptimekuma url must be absolute with scheme and host\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote URL values in YAML to avoid special-character issues","Trim whitespace from pasted URLs","Always include scheme (https://) and host in the configured URL"],"tags":["go","url-parsing","config","uptime-kuma"],"backgroundTag":"invalid-url-format","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}