kubernetes/kops · error

parsing Azure Blob location: %w

Error message

parsing Azure Blob location: %w

What it means

escapeBlobLocation parses the Azure Blob URL with url.Parse; this error is thrown when parsing itself fails, before any scheme/shape validation. The wrapped error from url.Parse identifies the exact syntax problem.

Source

Thrown at pkg/model/resources/nodeup.go:298

	return strings.Join(locations, ","), nil
}

func escapeS3Location(location string) (string, error) {
	u, err := url.Parse(location)
	if err != nil {
		return "", fmt.Errorf("parsing S3 location: %w", err)
	}
	if u.Scheme != "s3" || u.Host == "" {
		return "", fmt.Errorf("invalid S3 location")
	}

	return "s3://" + u.Host + httpbinding.EscapePath(u.Path, false), nil
}

func escapeBlobLocation(location string) (string, error) {
	u, err := url.Parse(location)
	if err != nil {
		return "", fmt.Errorf("parsing Azure Blob location: %w", err)
	}
	container, key, _ := strings.Cut(strings.TrimPrefix(u.Path, "/"), "/")
	// Reject ports, IPv6 hosts, userinfo, queries, and fragments, which the account-based
	// blob.core.windows.net URL cannot represent, so they fail here instead of in the boot retry loop.
	if u.Scheme != "azureblob" || u.Host == "" || u.Hostname() != u.Host || u.User != nil || u.RawQuery != "" || u.Fragment != "" || container == "" || key == "" {
		return "", fmt.Errorf("invalid Azure Blob location; expected azureblob://<account>/<container>/<key>")
	}

	return "azureblob://" + u.Host + httpbinding.EscapePath(u.Path, false), nil
}

func (b *NodeUpScript) Build() (fi.Resource, error) {
	if b.ProxyEnv == nil {
		b.ProxyEnv = funcEmptyString
	}
	if b.EnvironmentVariables == nil {
		b.EnvironmentVariables = funcEmptyString
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Fix the URL syntax per the wrapped url.Parse message.
  2. Use the canonical form azureblob://<account>/<container>/<key> with percent-encoding for special characters in the key.
  3. Strip SAS tokens/queries — pass credentials out of band, not in the source URL.
  4. Test with url.Parse in a scratch Go program before applying.

Example fix

// before
NodeUpSource: "azureblob://myaccount/container/path with space/nodeup"
// after
NodeUpSource: "azureblob://myaccount/container/path%20with%20space/nodeup"
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(location)
if err != nil {
    return fmt.Errorf("azureblob location not a valid URL: %w", err)
}

Type guard

func parsesAsURL(s string) bool { _, err := url.Parse(s); return err == nil }

Try / catch

escaped, err := escapeBlobLocation(loc)
if err != nil {
    return fmt.Errorf("fix azureblob:// URL syntax: %w", err)
}

Prevention

When it happens

Trigger: A nodeup source location with the azureblob:// scheme that fails Go's url.Parse, e.g. invalid percent-encodings, control characters, or an unparseable host portion.

Common situations: Pasting an https:// blob SAS URL with '?' SAS tokens and '&' into the azureblob source field, or embedding characters like spaces or stray brackets in the account/container/key path.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/3f587988fee2e810. Report an issue: GitHub.