{"record":{"id":"07f2f830f0942008","repo":"golang-migrate/migrate","slug":"no-scheme","errorCode":null,"errorMessage":"no scheme","messagePattern":"no scheme","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/url/url.go","lineNumber":8,"sourceCode":"package url\n\nimport (\n\t\"errors\"\n\t\"strings\"\n)\n\nvar errNoScheme = errors.New(\"no scheme\")\nvar errEmptyURL = errors.New(\"URL cannot be empty\")\n\n// schemeFromURL returns the scheme from a URL string\nfunc SchemeFromURL(url string) (string, error) {\n\tif url == \"\" {\n\t\treturn \"\", errEmptyURL\n\t}\n\n\ti := strings.Index(url, \":\")\n\n\t// No : or : is the first character.\n\tif i < 1 {\n\t\treturn \"\", errNoScheme\n\t}\n\n\treturn url[0:i], nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/internal/url/url.go#L1-L26","documentation":"internal/url's SchemeFromURL returns errNoScheme ('no scheme') when the connection-string URL has no scheme, i.e. there is no ':' with at least one character before it. The migrate CLI uses this function to map a database URL to its registered driver package, so a scheme-less URL cannot be routed to any driver.","triggerScenarios":"Calling migrate against a URL like 'localhost:5432/db'? No — precisely strings with no ':' before index 1, e.g. 'hello', or URLs passed via -database/-source that lack the 'driver://' prefix; SchemeFromURL('hello') returns errNoScheme.","commonSituations":"Forgetting the 'postgres://' or 'mysql://' prefix in -database/-source flags; env variables like DATABASE_URL missing the scheme; shell quoting stripping parts of the URL; new driver URLs the migrate version doesn't know how to parse.","solutions":["Prefix the URL with its driver scheme, e.g. postgres://user:pass@host/db, mysql://..., or file:// for -source.","Verify the DATABASE_URL / flag value actually contains the scheme (echo it before use).","Quote the URL in shell scripts so special characters aren't consumed.","Update golang-migrate if you use a valid driver scheme that your older version doesn't support."],"exampleFix":"// before\nmigrate -path ./migrations -database \"mydb.example.com:5432/app\" up\n// after\nmigrate -path ./migrations -database \"postgres://user:pass@mydb.example.com:5432/app?sslmode=disable\" up","handlingStrategy":"validation","validationCode":"func requireScheme(u string) error {\n\tif i := strings.Index(u, \":\"); i < 1 {\n\t\treturn errors.New(\"URL must include a driver scheme, e.g. postgres://...\")\n\t}\n\treturn nil\n}\n// check before: requireScheme(databaseURL)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use full driver URLs like postgres://user:pass@host/db, never bare host:port","Keep -database/-source values in env with the scheme included, and echo/validate at startup","Quote URLs in shell scripts so special characters don't get stripped","Handle errors.Is(err, url.ErrNoScheme)-style failures by printing the expected scheme format"],"tags":["go","golang-migrate","url","missing-scheme"],"backgroundTag":"missing-url-scheme","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}