docker-mailman icon indicating copy to clipboard operation
docker-mailman copied to clipboard

entrypoint.sh wait_for_mysql() fails to parse DATABASE_URL string that includes '#'

Open mistermatt2u opened this issue 3 years ago • 3 comments

The Python parsing command that extracts the database container hostname fails if a '#' character is present, likely in the password. This example DATABASE_URL value below prevents both mailman-core and mailman-web containers from successfully starting. They will just log "MYSQL is unavailable - sleeping" over and over.

mysql+pymysql://mailman:MdK-WvE#FgiB#rSZV6U%3oR^L@database/mailmandb

Thru testing of various passwords, I isolated the problem character to the '#'. The string is parsed correctly when only those characters are removed. The command used in entrypoint.sh's wait_for_mysql() function (python3 -c "from urllib.parse import urlparse; o = urlparse('$DATABASE_URL'); print(o.hostname);") to parse out the database hostname returns the value 'mailman' when using the example above. The correct return value should be 'database'. Since the incorrect hostname is parsed from the string, mailman-web and mailman-core are both unable to connect to the database.

I believe this problem also occurs on postgres database connections as well; but I did not test it to confirm it.

This seems to be a bug or limitation with the python3 urlparse function itself. If there is no alternative, perhaps a note in the docker-mailman documentation to not use the "#" character will help other people avoid the struggle I had.

mistermatt2u avatar Oct 17 '20 05:10 mistermatt2u

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.96. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Oct 17 '20 05:10 issue-label-bot[bot]

While reviewing the urllib.parse documentation, I found the excerpt below:

Characters in the netloc attribute that decompose under NFKC normalization (as used by the IDNA encoding) into any of /, ?, #, @, or : will raise a ValueError. If the URL is decomposed before parsing, no error will be raised.

This seems to indicate this is a known limitation of the function. So perhaps just putting a note in the docker-mailman documentation to avoid using the characters identified above would help people avoid problems.

mistermatt2u avatar Oct 17 '20 06:10 mistermatt2u

@maxking I'll take this one as well, and will submit a PR.

mistermatt2u avatar Jan 11 '21 01:01 mistermatt2u

This issue has not been updated for more than 1year

github-actions[bot] avatar Oct 27 '22 22:10 github-actions[bot]