Skip to content

Commit bca3d92

Browse files
committed
return error if port not defined in dsn
1 parent fa0924d commit bca3d92

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/dsn/dsn.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func Parse(dsn string) (info parsedInfo, err error) {
5050
if err != nil {
5151
return info, xerrors.WithStackTrace(err)
5252
}
53+
if port := uri.Port(); port == "" {
54+
return info, xerrors.WithStackTrace(fmt.Errorf("bad connection string '%s': port required", dsn))
55+
}
5356
info.Endpoint = uri.Host
5457
info.Database = uri.Path
5558
info.Secure = uri.Scheme != insecureSchema

0 commit comments

Comments
 (0)