wtfutil/wtf · error

URL is not defined

Error message

URL is not defined

What it means

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.

Source

Thrown at modules/uptimekuma/widget.go:217

	if resp != nil && resp.StatusCode != 200 {
		return nil, fmt.Errorf("%s", resp.Status)
	}
	if resp == nil || err != nil {
		return nil, err
	}
	defer func() { _ = resp.Body.Close() }()

	var data HeartbeatData
	if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
		return nil, err
	}

	return &data, nil
}

func parseURL(rawURL string) (string, string, error) {
	if rawURL == "" {
		return "", "", fmt.Errorf("URL is not defined")
	}

	u, err := url.Parse(rawURL)
	if err != nil {
		return "", "", fmt.Errorf("invalid URL: %w", err)
	}

	parts := strings.Split(strings.Trim(u.Path, "/"), "/")
	if len(parts) < 2 || parts[0] != "status" {
		return "", "", fmt.Errorf("invalid status page URL format. Expected '.../status/<slug>'")
	}

	slug := parts[1]
	baseURL := fmt.Sprintf("%s://%s", u.Scheme, u.Host)

	return baseURL, slug, nil
}

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. 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"
  2. If the URL comes from an environment variable, confirm the variable is exported and non-empty before launching the app
  3. Restart/reload after editing the config so Refresh picks up the new value

Example fix

// before
uptimekuma:
  url: ""
// after
uptimekuma:
  url: "https://uptime.example.com/status/main"
Defensive patterns

Strategy: validation

Validate before calling

// before configuring the widget
if urlValue == "" {
    return fmt.Errorf("uptimekuma widget requires a non-empty url like https://host/status/<slug>")
}

Prevention

When it happens

Trigger: 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: "".

Common situations: 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.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/3c8daf205f250dec. Report an issue: GitHub.