{"record":{"id":"2a15b638de4036da","repo":"golang-migrate/migrate","slug":"not-implemented","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"source/godoc_vfs/vfs.go","lineNumber":34,"sourceCode":"\nfunc init() {\n\tsource.Register(\"godoc-vfs\", &VFS{})\n}\n\n// VFS is an implementation of driver that returns migrations from a virtual\n// file system.\ntype VFS struct {\n\thttpfs.PartialDriver\n\tfs   vfs.FileSystem\n\tpath string\n}\n\n// Open implements the source.Driver interface for VFS.\n//\n// Calling this function panics, instead use the WithInstance function.\n// See the package level documentation for an example.\nfunc (b *VFS) Open(url string) (source.Driver, error) {\n\tpanic(\"not implemented\")\n}\n\n// WithInstance creates a new driver from a virtual file system.\n// If a tree named searchPath exists in the virtual filesystem, WithInstance\n// searches for migration files there.\n// It defaults to \"/\".\nfunc WithInstance(fs vfs.FileSystem, searchPath string) (source.Driver, error) {\n\tif searchPath == \"\" {\n\t\tsearchPath = \"/\"\n\t}\n\n\tbn := &VFS{\n\t\tfs:   fs,\n\t\tpath: searchPath,\n\t}\n\n\tif err := bn.Init(vfs_httpfs.New(fs), searchPath); err != nil {\n\t\treturn nil, err","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/godoc_vfs/vfs.go#L16-L52","documentation":"VFS.Open intentionally panics with \"not implemented\": a VFS-backed source driver cannot be constructed from a URL because the underlying virtual filesystem must be supplied as a value. The package docs say to use godoc_vfs.WithInstance instead; Open exists only to satisfy the source.Driver interface.","triggerScenarios":"Calling migrate.New/NewWithDatabaseConnection with a URL scheme registered to the VFS source driver, or calling vfsInstance.Open(url) directly on a godoc_vfs.VFS value.","commonSituations":"Treating the VFS driver like file:// or other URL-based drivers; older code using the deprecated godoc-vfs pattern (v3 and earlier) migrating to newer APIs; copy-pasted migrate.New(\"vfs://...\", dsn) calls.","solutions":["Call godoc_vfs.WithInstance(vfsInstance, searchPath) to obtain the source.Driver instead of Open.","Pass that driver to migrate.NewWithInstance(srcDrv, dbDrv) rather than using URL-based migrate.New.","If you only need filesystem-based migrations, use the iofs or file source driver with a URL instead.","Wrap calls in a recover() if you must call arbitrary URL schemes and treat this panic as a config error."],"exampleFix":"// before\nm, err := migrate.New(\"vfs:///migrations\", \"postgres://...\") // panics\n// after\nsrc, err := godoc_vfs.WithInstance(myVfs, \"/migrations\")\nm, err := migrate.NewWithInstance(\"vfs\", src, \"postgres\", dbDrv)","handlingStrategy":"validation","validationCode":"// never route vfs through URL-based migrate.New; use WithInstance directly\nif strings.HasPrefix(url, \"vfs\") {\n\treturn errors.New(\"vfs source requires godoc_vfs.WithInstance, not migrate.New\")\n}","typeGuard":null,"tryCatchPattern":"func safeVfsOpen(v *godoc_vfs.VFS, url string) (src source.Driver, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"vfs.Open panicked (use WithInstance): %v\", r)\n\t\t}\n\t}()\n\treturn v.Open(url)\n}","preventionTips":["Always use godoc_vfs.WithInstance(vfs, searchPath) + migrate.NewWithInstance for VFS-backed migrations.","Never pass vfs-style URLs to migrate.New; only URL-capable drivers support it.","Read the godoc_vfs package example before integrating; Open is intentionally a panic stub.","If migrating from v3 code, replace VFS usage with the iofs driver where possible."],"tags":["go","migrate","vfs","panic","not-implemented"],"backgroundTag":"method-not-implemented-panic","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}