Parse the MySQL address with net.SplitHostPort - #829
Closed
arpitjain099 wants to merge 1 commit into
Closed
Conversation
✅ Deploy Preview for archivista-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
jkjell
approved these changes
Sep 4, 2026
ConfigFromMySQL split dbConfig.Addr on ":" and indexed element 1. go-sql-driver's ParseDSN only fills in a default port when Net is "tcp", so a unix socket DSN leaves Addr as a bare socket path with no colon: user:pass@unix(/tmp/mysql.sock)/testify panic: runtime error: index out of range [1] with length 1 NewEntClient and RewriteConnectionStringForIAM both call this with the configured connection string, so the server binary crashed at startup instead of reporting a bad configuration. The same split mis-handled a bracketed IPv6 host, leaving Host as "[" and failing with an empty-port Atoi error. net.SplitHostPort handles both, and a non-tcp network is now an explicit error naming what is supported. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
jkjell
force-pushed
the
fix/mysql-dsn-addr-parsing
branch
from
September 4, 2026 12:51
2f539e5 to
98236a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ConfigFromMySQLsplitsdbConfig.Addron":"and indexes element 1:go-sql-driver's
ParseDSNonly fills in a default port whenNetis"tcp". For a unix socket DSN it leavesAddras a bare socket path with no colon, so there is no element 1:Both production callers reach it with the configured connection string,
NewEntClientinclient.goandRewriteConnectionStringForIAMiniam.go, so a socket DSN takes the server down at startup rather than reporting a bad configuration.The third line is a second, quieter problem from the same split: a bracketed IPv6 host leaves
Hostas"["and the port empty.net.SplitHostPorthandles both shapes, and a non-tcp network is now an explicit error that says what is supported rather than a panic.Added
utils_test.gocovering tcp, IPv6, the unix socket, and an unparseable DSN. Without the change the IPv6 and unix cases both fail, the latter by panicking.