{"record":{"id":"9327765c9aa650a4","repo":"golang-migrate/migrate","slug":"expected-bitbucket-client","errorCode":null,"errorMessage":"expected *bitbucket.Client","messagePattern":"expected \\*bitbucket\\.Client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"source/bitbucket/bitbucket.go","lineNumber":24,"sourceCode":"\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}\n\nfunc (b *Bitbucket) Open(url string) (source.Driver, error) {\n\tu, err := nurl.Parse(url)","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/bitbucket/bitbucket.go#L6-L42","documentation":"ErrInvalidBitbucketClient is the sentinel error the bitbucket source driver uses when WithInstance (or New) receives a client argument that is not a *bitbucket.Client from github.com/ktrysmt/go-bitbucket. It is an exported error used for type-assertion failures on the driver's internal client field.","triggerScenarios":"Calling bitbucket.WithInstance with a nil or wrongly-typed client, or constructing the driver so its client field holds something other than *bitbucket.Client; typically a programming error, not a runtime/config error.","commonSituations":"Passing a custom HTTP client wrapper instead of *bitbucket.Client; nil client after a failed constructor; refactoring that changed the client type; tests stubbing the client with the wrong type.","solutions":["Create the client with bitbucket.NewBasicAuth(username, appPassword) from go-bitbucket and pass that to WithInstance.","Check for a nil client before calling WithInstance.","Update imports to use github.com/ktrysmt/go-bitbucket's Client type if you migrated from another library.","In tests, use the same concrete type or an interface seam instead of a mismatched stub."],"exampleFix":"// before\nb.WithInstance(someHTTPClient, cfg)\n// after\ncl := bitbucket.NewBasicAuth(user, pass)\nb.WithInstance(cl, cfg)","handlingStrategy":"type-guard","validationCode":"if cl == nil {\n    return fmt.Errorf(\"bitbucket client must be created via bitbucket.NewBasicAuth(user, appPassword)\")\n}\nif _, ok := interface{}(cl).(*bitbucket.Client); !ok {\n    return fmt.Errorf(\"wrong client type %T\", cl)\n}","typeGuard":"func isBitbucketClient(c interface{}) bool {\n    _, ok := c.(*bitbucket.Client)\n    return ok\n}","tryCatchPattern":"d, err := bitbucket.WithInstance(cl, cfg)\nif errors.Is(err, bitbucket.ErrInvalidBitbucketClient) {\n    return fmt.Errorf(\"pass *bitbucket.Client from go-bitbucket, got %T\", cl)\n}","preventionTips":["Always construct the client with bitbucket.NewBasicAuth.","Nil-check the client before WithInstance.","Don't wrap the client in custom types when passing to the driver.","Keep go-bitbucket dependency versions aligned."],"tags":["bitbucket","type-error","client","programming"],"backgroundTag":"invalid-client-type","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}