matrix-org / sydent

Sydent: Reference Matrix Identity Server

Home Page:http://matrix.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[docker] Bad working directory

guimard opened this issue · comments

commented

When trying to register an email using matrixdotorg/sydent, using the following command, I receive a 500 error:

$ curl -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"client_secret": "mysecret","email": "user@domain.com","send_attempt": 1,"id_server":"https://matrix.domain.com","next_link":"https://domain.com"}' 'http://localhost:8090/_matrix/identity/api/v1/validate/email/requestToken';echo
{"errcode": "M_UNKNOWN", "error": "Internal Server Error"}

Here are the docker logs

2023-03-06 05:21:54,032 - sydent.validators.emailvalidator - 91 - INFO - Attempting to mail code oCX4yCMl9y25xDCIXYTiApw6l1l9TZn1 (nextLink: https://domain.com) to user@domain.com
2023-03-06 05:21:54,032 - sydent.http.servlets - 184 - ERROR - Exception processing request
Traceback (most recent call last):
  File "/home/sydent/src/sydent/http/servlets/__init__.py", line 179, in inner
    return dict_to_json_bytes(f(self, request))
  File "/home/sydent/src/sydent/http/servlets/emailservlet.py", line 102, in render_POST
    sid = self.sydent.validators.email.requestToken(
  File "/home/sydent/src/sydent/validators/emailvalidator.py", line 97, in requestToken
    sendEmail(self.sydent, templateFile, emailAddress, substitutions)
  File "/home/sydent/src/sydent/util/emailutils.py", line 85, in sendEmail
    with open(templateFile) as template_file:
FileNotFoundError: [Errno 2] No such file or directory: 'res/matrix-org/verification_template.eml'
2023-03-06 05:21:54,033 - twisted - 147 - INFO - "::ffff:172.17.0.1" - - [06/Mar/2023:05:21:53 +0000] "POST /_matrix/identity/api/v1/validate/email/requestToken HTTP/1.1" 500 58 "-" "curl/7.88.1"

The requested file exists in the docker image but isn't found

$ ls -l /home/sydent/src/res/matrix-org/
total 36
-rw-r--r-- 1 sydent sydent 5075 Mar  2 18:47 invite_template.eml
-rw-r--r-- 1 sydent sydent 5366 Mar  2 18:47 invite_template.eml.j2
-rw-r--r-- 1 sydent sydent 4648 Mar  2 18:47 migration_template.eml.j2
-rw-r--r-- 1 sydent sydent 2736 Mar  2 18:47 verification_template.eml
-rw-r--r-- 1 sydent sydent 2812 Mar  2 18:47 verification_template.eml.j2
-rw-r--r-- 1 sydent sydent  121 Mar  2 18:47 verify_response_template.html

Looking at the process, the working directory is "/home/sydent" instead of "/home/sydent/src", that's why it fails to find the file. Strace extract:

openat(AT_FDCWD, "res/matrix-org/verification_template.eml", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
commented

Workaround, fix sydent.conf:

[general]
templates.path = /home/sydent/src/res