{"record":{"id":"4f7f2e2c49a96aa5","repo":"golang-migrate/migrate","slug":"no-username-password-provided","errorCode":null,"errorMessage":"no username:password provided","messagePattern":"no username:password provided","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"source/bitbucket/bitbucket.go","lineNumber":21,"sourceCode":"import (\n\t\"fmt\"\n\t\"io\"\n\tnurl \"net/url\"\n\t\"os\"\n\t\"path\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/golang-migrate/migrate/v4/source\"\n\t\"github.com/ktrysmt/go-bitbucket\"\n)\n\nfunc init() {\n\tsource.Register(\"bitbucket\", &Bitbucket{})\n}\n\nvar (\n\tErrNoUserInfo             = fmt.Errorf(\"no username:password provided\")\n\tErrNoAccessToken          = fmt.Errorf(\"no password/app password\")\n\tErrInvalidRepo            = fmt.Errorf(\"invalid repo\")\n\tErrInvalidBitbucketClient = fmt.Errorf(\"expected *bitbucket.Client\")\n\tErrNoDir                  = fmt.Errorf(\"no directory\")\n)\n\ntype Bitbucket struct {\n\tconfig     *Config\n\tclient     *bitbucket.Client\n\tmigrations *source.Migrations\n}\n\ntype Config struct {\n\tOwner string\n\tRepo  string\n\tPath  string\n\tRef   string\n}","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/bitbucket/bitbucket.go#L3-L39","documentation":"ErrNoUserInfo is returned by the bitbucket source driver's Open when the source URL contains no user info component. The driver builds a basic-auth Bitbucket client from the URL, so it requires a username in the URL. It is an exported sentinel error comparable with errors.Is.","triggerScenarios":"Opening a bitbucket source URL without credentials, e.g. `bitbucket://owner/repo/path#ref` or `bitbucket://owner@host/...` with no `:password`, so u.User is nil after url.Parse.","commonSituations":"Forgetting to embed credentials in the source URL in migrate config; removing the password for 'security' but leaving out the username too; URL built programmatically without user info; env-substituted URL where credentials vars were empty.","solutions":["Include a username (and password) in the URL: `bitbucket://username:app-password@owner/repo/migrations#branch`.","Verify the URL string in your config/scripts actually contains `user:pass@` after env substitution.","Use an app password (Bitbucket requires basic auth), not your account password or an OAuth token, in the password slot.","Compare with errors.Is(err, bitbucket.ErrNoUserInfo) in code to give a clear config error to users."],"exampleFix":"// before\nurl := \"bitbucket://myteam/myrepo/migrations#master\"\n// after\nurl := \"bitbucket://myuser:my-app-password@myteam/myrepo/migrations#master\"","handlingStrategy":"validation","validationCode":"u, err := nurl.Parse(sourceURL)\nif err != nil {\n    return err\n}\nif u.Scheme == \"bitbucket\" && u.User == nil {\n    return fmt.Errorf(\"bitbucket source URL requires user:password, got %q\", sourceURL)\n}","typeGuard":"func hasURLUserInfo(u *nurl.URL) bool {\n    return u != nil && u.User != nil && u.User.Username() != \"\"\n}","tryCatchPattern":"d, err := bitbucket.Open(url)\nif errors.Is(err, bitbucket.ErrNoUserInfo) {\n    return fmt.Errorf(\"bitbucket source needs basic auth in URL: bitbucket://user:app-password@owner/repo#ref\")\n}","preventionTips":["Always build source URLs as scheme://user:pass@host/path#ref.","Verify env-var interpolation produces non-empty credentials.","Use a Bitbucket app password with repo read scope.","Centralize URL construction in one helper that asserts user info."],"tags":["bitbucket","authentication","url","config"],"backgroundTag":"missing-url-credentials","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}