Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docker] Bad working directory #556

Open
guimard opened this issue Mar 6, 2023 · 1 comment
Open

[docker] Bad working directory #556

guimard opened this issue Mar 6, 2023 · 1 comment

Comments

@guimard
Copy link

guimard commented Mar 6, 2023

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": "[email protected]","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 [email protected]
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)
@guimard
Copy link
Author

guimard commented Mar 6, 2023

Workaround, fix sydent.conf:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants