kubernetes/kops · error

path type %T for %q does not implement WriteToWithContext

Error message

path type %T for %q does not implement WriteToWithContext

What it means

After building the vfs.Path for a gs/s3/azureblob URL, the code asserts the concrete type implements vfs.WriterToWithContext. If a path type lacks this interface, downloads cannot be streamed and this error names the type and URL. This is an internal capability mismatch, typically from an unsupported/custom vfs path implementation.

Source

Thrown at upup/pkg/fi/http.go:113

	algorithm := hashing.HashAlgorithmSHA256
	if hash != nil {
		algorithm = hash.Algorithm
	}
	hasher := algorithm.NewHasher()
	writer := io.MultiWriter(dest, hasher)

	switch u.Scheme {
	case "gs", "s3", "azureblob":
		// vfs resolves the bucket and signs the request with the ambient cloud credentials,
		// such as the instance identity.
		p, err := vfs.Context.BuildVfsPath(desturl)
		if err != nil {
			return nil, fmt.Errorf("building path for %q: %w", desturl, err)
		}
		cloudPath, ok := p.(vfs.WriterToWithContext)
		if !ok {
			return nil, fmt.Errorf("path type %T for %q does not implement WriteToWithContext", p, desturl)
		}
		if _, err := cloudPath.WriteToWithContext(ctx, writer); err != nil {
			return nil, fmt.Errorf("error downloading content from %q: %w", desturl, err)
		}
	default:
		reader, err := OpenURL(desturl)
		if err != nil {
			return nil, err
		}
		defer reader.Close()

		if _, err := io.Copy(writer, reader); err != nil {
			return nil, fmt.Errorf("error downloading HTTP content from %q: %v", desturl, err)
		}
	}

	actual := &hashing.Hash{
		Algorithm: algorithm,

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Note the %T type in the error to identify which path implementation is used
  2. Confirm you are on an unmodified, current kops build
  3. If custom vfs code is involved, implement vfs.WriterToWithContext on that path type
  4. Work around by serving the file over an HTTP(S) URL instead

Example fix

// before
type myPath struct{...} // no WriteToWithContext
// after
func (p *myPath) WriteToWithContext(ctx context.Context, w io.Writer) (int64, error) { ... }
Defensive patterns

Strategy: type-guard

Type guard

func supportsStreaming(p vfs.Path) bool {
    _, ok := p.(vfs.WriterToWithContext)
    return ok
}

Try / catch

if _, err := fi.DownloadURL(ctx, assetURL, dest, nil); err != nil {
    if strings.Contains(err.Error(), "does not implement WriteToWithContext") {
        return fmt.Errorf("vfs path for %s lacks streaming support; use an HTTPS mirror", assetURL)
    }
    return err
}

Prevention

When it happens

Trigger: A type assertion p.(vfs.WriterToWithContext) fails for a cloud-storage path — i.e. a vfs path implementation that does not support context-aware streaming writes.

Common situations: Custom or older vfs path types registered for the scheme; using a forked/modified kops where a new vfs backend lacks WriteToWithContext.

Related errors


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