Skip to content

Commit

Permalink
source-mongodb: better error message when url is for online-archive
Browse files Browse the repository at this point in the history
Mongodb has an "online archive" service, which looks a lot like mongodb but
doesn't work with our connector.  This adds an explicit check for URLs that
appear to be for that service, and returns a clearer error message in case
someone uses such a URL.
  • Loading branch information
psFried committed Jan 19, 2024
1 parent 513176d commit aeda95d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source-mongodb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/url"
"slices"
"strings"
"time"

cerrors "github.com/estuary/connectors/go/connector-errors"
Expand Down Expand Up @@ -103,6 +104,15 @@ func (c *config) ToURI() string {
type driver struct{}

func (d *driver) Connect(ctx context.Context, cfg config) (*mongo.Client, error) {
// Mongodb atlas offers an "online-archive" service, which does not work
// with this connector because it doesn't support change streams. Their UI
// makes it really easy to grab the wrong URL, so this check exists to provide
// a more helpful error message in the event that someone tries to use the
// online-archive url instead of the regular mongodb url.
if strings.Contains(cfg.Address, "atlas-online-archive") {
return nil, fmt.Errorf("The provided URL appears to be for 'Atlas online archive', which is not supported by this connector. Please use the regular cluster URL instead")
}

// Create a new client and connect to the server
var opts = options.Client().ApplyURI(cfg.ToURI()).SetCompressors([]string{"zstd", "zlib", "snappy"})
client, err := mongo.Connect(ctx, opts)
Expand Down

0 comments on commit aeda95d

Please sign in to comment.