Discourse-setup generates malformed YAML if password contains ':'

AI-generated summary

A bug was reported where running ./discourse-setup with an DISCOURSE_SMTP_PASSWORD containing a colon (:) generated malformed YAML, causing a syntax error during Docker image initialization csirac2. The error message indicated that mapping values were not allowed in the context, specifically at line 62 of the configuration. The user resolved the issue manually by quoting the password value in app.yaml and suggested the setup script should handle quoting automatically.

codinghorror acknowledged the issue, noting previous hesitation to quote passwords in raw YAML files to avoid ambiguity regarding whether quotes were part of the password itself. However, agreeing that automating double quotes around the DISCOURSE_SMTP_PASSWORD within the setup script is a clear solution, he implemented a fix in the repository codinghorror. The commit ensures the password is properly quoted to prevent YAML syntax errors, while other fields were deemed unlikely to require similar protection.

During initial ./discourse-setup using 1475ee4554ba7895cf3410f6181bb96155c7b5b3 the DISCOURSE_SMTP_PASSWORD contained a full-colon character : which resulted in an error after pulling down the docker image:

(): mapping values are not allowed in this context at line 62 column 42 -e LANG=en_US.UTF-8
YAML syntax error. Please check your containers/*.yml config files.

That was the final two lines of output from the script. I fixed app.yaml by simply quoting the DISCOURSE_SMTP_PASSWORD value.

./discourse-setup should probably be properly quoting all of these yaml responses anyway.

3 Me gusta

Yes, excellent point! I was afraid to put this in the raw YAML file to avoid the implied “who’s on first” problem of whether double quotes are part of the password or not. This came up before and we discussed it, but decided to leave it as a comment.

But within discourse-setup adding double quotes around the DISCOURSE_SMTP_PASSWORD is a no-brainer and can be automated, so I’ve done that:

https://github.com/discourse/discourse_docker/commit/6a9f41e996d3c2b10f1151159b54bfd4f649e10d

(I don’t think the other fields will typically contain any unusual characters and thus don’t benefit from this kind of protection like password field does.)

4 Me gusta