You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Automatically handle seeing a port 3306 in a connection string #144
port 3306 can never work for us, and it's common that a DATABASE_URL that you've used in another environemnt that was a traditional mysql driver looks something like: mysql://user:pass@aws.connect.psdb.cloud:3306/dbname
We already ignore the mysql:// protocol and rewrite it to https://, so we should similarly drop the 3306 if a connection is overly explicit.
I checked the part where we parse the connection string and it is transformed into an URL object (here). We can use the port property in this URL object to check if it is allowed or not. We can simply create a list of not-allowed ports in a constants file and check if the port that we got from the URL object lies there or not, based on which we can proceed with the connection or throw and error.
That's more what I'd expect for implementation. I don't think we need to even go that complex though, and I feel we only need to special case 3306 and coerce it to https/443. I don't think there's any reason to maintain anything else.
Hi @mattrobenolt, I see there's an existing PR (#211) for this but it
has been open for a few weeks without review. I'd like to take a shot
at this as well with a clean implementation. Would you be open to
reviewing a new PR, or should I wait for #211 to be resolved first?
Activity
kailash360 commentedon Dec 20, 2023
We can use RegEx to recognize port number in the connection string. Can I take up this issue?
mattrobenolt commentedon Dec 20, 2023
I don't think we need a regular expression here, we already fully parse the URL, it should have the port already I'd suspect, I haven't looked much.
kailash360 commentedon Dec 27, 2023
I checked the part where we parse the connection string and it is transformed into an URL object (here). We can use the
portproperty in this URL object to check if it is allowed or not. We can simply create a list of not-allowed ports in a constants file and check if theportthat we got from the URL object lies there or not, based on which we can proceed with the connection or throw and error.mattrobenolt commentedon Dec 27, 2023
That's more what I'd expect for implementation. I don't think we need to even go that complex though, and I feel we only need to special case 3306 and coerce it to https/443. I don't think there's any reason to maintain anything else.
clanzhang commentedon Jul 21, 2026
Hi @mattrobenolt, I see there's an existing PR (#211) for this but it
has been open for a few weeks without review. I'd like to take a shot
at this as well with a clean implementation. Would you be open to
reviewing a new PR, or should I wait for #211 to be resolved first?