grafana/k6 · error

urlTemplate is not a valid URL: %w

Error message

urlTemplate is not a valid URL: %w

What it means

validateURLTemplate substituted the {key} placeholder with a dummy value and url.Parse rejected the result, meaning the configured urlTemplate is not syntactically a URL. This is a config validation guard: the template already passed the empty-string and placeholder checks, so the raw URL syntax itself is at fault.

Source

Thrown at internal/secretsource/url/url.go:532

	return fileCfg, nil
}

func validateURLTemplate(urlTemplate string) error {
	if urlTemplate == "" {
		return errMissingURLTemplate
	}

	// Require {key} placeholder to differentiate between secrets
	if !strings.Contains(urlTemplate, "{key}") {
		return errors.New("urlTemplate must contain {key} placeholder")
	}

	// Replace {key} placeholder with a dummy value for validation
	testURL := strings.ReplaceAll(urlTemplate, "{key}", "test")
	parsedURL, err := url.Parse(testURL)
	if err != nil {
		return fmt.Errorf("urlTemplate is not a valid URL: %w", err)
	}

	// Require absolute URL with scheme
	if parsedURL.Scheme == "" {
		return errors.New("urlTemplate must be an absolute URL with a scheme (e.g., https://...)")
	}

	return nil
}

func getConfig(arg string, fs fsext.Fs, env map[string]string) (extConfig, error) {
	// Start with defaults
	config := newConfig()

	// Apply environment variables
	// Order of precedence (lowest to highest):
	// 1. Defaults
	// 2. Environment variables

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Fix the urlTemplate value in the URL secret source config so it is an absolute URL with a scheme and host
  2. Ensure the {key} placeholder remains in the template but the surrounding text parses as a URL (no stray spaces, brackets or invalid characters)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/secretsource/url/url.go:532 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/13e138b6a49cea9b. Report an issue: GitHub.