{"record":{"id":"3c8daf205f250dec","repo":"wtfutil/wtf","slug":"url-is-not-defined","errorCode":null,"errorMessage":"URL is not defined","messagePattern":"URL is not defined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/uptimekuma/widget.go","lineNumber":217,"sourceCode":"\tif resp != nil && resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"%s\", resp.Status)\n\t}\n\tif resp == nil || err != nil {\n\t\treturn nil, err\n\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":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/uptimekuma/widget.go#L199-L235","documentation":"parseURL in the Uptime Kuma widget validates the configured status page URL before constructing API requests. It returns 'URL is not defined' when the widget's configured URL string is empty, because a status page slug and base URL cannot be derived from nothing. This is a configuration error, not a runtime/network failure.","triggerScenarios":"Refresh calls parseURL with the widget's configured 'url' setting and it is an empty string — e.g. the uptimekuma widget block in the config omits the url key or sets url: \"\".","commonSituations":"Users add the uptimekuma widget and forget to fill in the URL; templated config values resolve to empty because an environment variable is unset; a config migration drops the url field.","solutions":["Set the url property in the uptimekuma widget config block to the full status page URL, e.g. url: \"https://uptime.example.com/status/main\"","If the URL comes from an environment variable, confirm the variable is exported and non-empty before launching the app","Restart/reload after editing the config so Refresh picks up the new value"],"exampleFix":"// before\nuptimekuma:\n  url: \"\"\n// after\nuptimekuma:\n  url: \"https://uptime.example.com/status/main\"","handlingStrategy":"validation","validationCode":"// before configuring the widget\nif urlValue == \"\" {\n    return fmt.Errorf(\"uptimekuma widget requires a non-empty url like https://host/status/<slug>\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set the full status page URL including /status/<slug> in the widget config","Validate config values at load time before widgets start","Source env-driven URLs from a single place and assert non-empty at startup"],"tags":["go","config","uptime-kuma","url-validation"],"backgroundTag":"missing-required-config-value","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"}