kubernetes/kops · error

memfs path not recognized: %q

Error message

memfs path not recognized: %q

What it means

buildMemFSPath builds an in-memory VFS path used mainly for testing. It only accepts strings with the memfs:// prefix; anything else is unrecognized because the in-memory filesystem has no other address form.

Source

Thrown at util/pkg/vfs/context.go:476

	if err != nil {
		return nil, fmt.Errorf("invalid kubernetes vfs path: %q", p)
	}
	if u.Scheme != "k8s" {
		return nil, fmt.Errorf("invalid kubernetes vfs path: %q", p)
	}

	bucket := strings.TrimSuffix(u.Host, "/")
	if bucket == "" {
		return nil, fmt.Errorf("invalid kubernetes vfs path: %q", p)
	}

	k8sPath := newKubernetesPath(c.k8sContext, bucket, u.Path)
	return k8sPath, nil
}

func (c *VFSContext) buildMemFSPath(p string) (*MemFSPath, error) {
	if !strings.HasPrefix(p, "memfs://") {
		return nil, fmt.Errorf("memfs path not recognized: %q", p)
	}
	location := strings.TrimPrefix(p, "memfs://")
	if c.memfsContext == nil {
		// We only initialize this in unit tests etc
		return nil, fmt.Errorf("memfs context not initialized")
	}
	fspath := NewMemFSPath(c.memfsContext, location)
	return fspath, nil
}

func (c *VFSContext) ResetMemfsContext(clusterReadable bool) {
	c.memfsContext = NewMemFSContext()
	if clusterReadable {
		c.memfsContext.MarkClusterReadable()
	}
}

func (c *VFSContext) buildGCSPath(p string) (*GSPath, error) {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Prefix the path with memfs:// exactly (double slash): memfs://some/location
  2. Check for typos like memfs:/ or memfs/// in test fixtures
  3. Confirm the value isn't a plain relative path accidentally passed in

Example fix

// before
p, err := vfs.Context.BuildVfsPath("/state/cluster")
// after
p, err := vfs.Context.BuildVfsPath("memfs:///state/cluster")
Defensive patterns

Strategy: validation

Validate before calling

if !strings.HasPrefix(p, "memfs://") {
	return fmt.Errorf("memfs path must start with memfs://, got %q", p)
}

Try / catch

p, err := vfs.Context.BuildVfsPath(p)
if err != nil {
	if strings.Contains(err.Error(), "memfs path not recognized") {
		return fmt.Errorf("prefix the path with memfs:// : %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: BuildVfsPath dispatches to buildMemFSPath with a path that does not start with "memfs://" — meaning an earlier scheme check routed a foreign path here while the string itself uses another or no scheme.

Common situations: Tests or tooling calling VFSContext.BuildVfsPath with a typo like memfs:/path (single slash) or memfs//path; passing a relative path or file:// path where a memfs:// path is expected.

Related errors


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