{"record":{"id":"bfe7f4f244ccafe0","repo":"golang-migrate/migrate","slug":"bad-scheme-w","errorCode":null,"errorMessage":"bad scheme: %w","messagePattern":"bad scheme: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"database/rqlite/rqlite.go","lineNumber":289,"sourceCode":"\t\treturn &database.Error{OrigErr: err, Query: []byte(strings.Join(statements, \"\\n\"))}\n\t}\n\n\treturn nil\n}\n\nfunc parseUrl(url string) (*nurl.URL, *Config, error) {\n\tparsedUrl, err := nurl.Parse(url)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tconfig, err := parseConfigFromQuery(parsedUrl.Query())\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tif parsedUrl.Scheme != \"rqlite\" {\n\t\treturn nil, nil, fmt.Errorf(\"bad scheme: %w\", ErrBadConfig)\n\t}\n\n\t// adapt from rqlite to http/https schemes\n\tif config.ConnectInsecure {\n\t\tparsedUrl.Scheme = \"http\"\n\t} else {\n\t\tparsedUrl.Scheme = \"https\"\n\t}\n\n\tfilteredUrl := migrate.FilterCustomQuery(parsedUrl)\n\n\treturn filteredUrl, config, nil\n}\n\nfunc parseConfigFromQuery(queryVals nurl.Values) (*Config, error) {\n\tc := Config{\n\t\tConnectInsecure: DefaultConnectInsecure,\n\t\tMigrationsTable: DefaultMigrationsTable,","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/database/rqlite/rqlite.go#L271-L307","documentation":"\"bad scheme: %w\" is raised in rqlite's parseUrl (rqlite.go:289) when the URL scheme is not exactly \"rqlite\", wrapping ErrBadConfig. Open expects a rqlite:// (or rqlites-style) URL and rewrites it internally to http/https, so any other scheme is a configuration error. The wrapped error text will read e.g. 'bad scheme: bad parameter'.","triggerScenarios":"Calling rqlite.Open(\"http://localhost:4001/db\") or \"https://...\" instead of \"rqlite://...\"; pasting an HTTP API endpoint URL directly into golang-migrate.","commonSituations":"Reusing the browser/API endpoint URL of an rqlite node as a DSN; environment variable DSNs set up for a different driver; scheme typos like rqlite+http.","solutions":["Change the URL scheme to rqlite:// (the driver maps it to http or https based on x-connect-insecure)","If you have an https endpoint, keep rqlite scheme and rely on default TLS, or set x-connect-insecure=false","Sanitize/validate the DSN scheme in code before calling migrate.New/WithURL"],"exampleFix":"// before\nurl := \"http://localhost:4001\"\nd, err := rqlite.Open(url) // bad scheme\n// after\nurl := \"rqlite://localhost:4001?x-connect-insecure=true\"\nd, err := rqlite.Open(url)","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(dsn)\nif u.Scheme != \"rqlite\" {\n    return fmt.Errorf(\"expected rqlite:// scheme, got %q\", u.Scheme)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store rqlite DSNs with the rqlite:// scheme even though the node is reached over HTTP(S)","Use x-connect-insecure to control TLS, not the scheme","Centralize DSN construction in one helper instead of hand-writing URLs"],"tags":["go","golang-migrate","rqlite","url-scheme","config"],"backgroundTag":"invalid-url-scheme","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}