-
-
Notifications
You must be signed in to change notification settings - Fork 278
Wrap creation of zuliprc in try to catch PermissionError. #801
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
Conversation
3795c44
to
d2fe1a3
Compare
@fredrikekre Thanks for debugging this. It looks like we hadn't thought about this permission issue when creating zuliprc files in mapped volumes. (It might be helpful if we add a note of running with There's one lint error in the PR which is causing CI to fail on Travis (Travis message says it's a line length exceeded issue). You can run our linters locally |
c2b73d7
to
c442df5
Compare
Should be fixed now.
I assume the |
c442df5
to
3d5a405
Compare
Previously OSErrors where caught in the outer try in the while loop in parse_zuliprc. This resulted in a misleading error message about invalid credentials. This patch catches OSErrors from open directly at the source, and exits directly since there is no point to keep asking the user for credentials. In particular, when running the default docker configuration, open throws PermissionError since the zulip user in the container does not have permission to create files in the mapped host folder. Fixes zulip#797.
3d5a405
to
c9c8b87
Compare
@fredrikekre This looks broadly good 👍 How did you test this? We have some tests for |
I just ran something like
and put in the credentials. It should be possible to add a test by calling |
@fredrikekre I have working test cases (via |
@fredrikekre I've used the approach suggested in the issue, resulting in https://github.com/neiljp/zulip-terminal/commits/801_with_tests I think this covers the likely cases which you were trying to fix? Your commit does clarify the message resulting from #797, which is great, but I'm not sure if it resolves the fundamental issue - ie. that the user ids/names don't match and so the fresh zuliprc cannot be written. Do you agree? |
Yea, feel free to push to this branch.
Sure, but with a correct error message I would instantly understand what the issue was and be able to resolve it (most docker users run into these permission errors sometimes I assume, and knows how to fix it). I can submit a follow up pull request adding some more detailed information about this to the |
@fredrikekre Given the apparent consensus, I was planning to just rebase/merge that branch onto master, unless you had other plans? We'd certainly welcome a follow-up for folks running docker to clarify this issue. (that is, push my branch with your commit and the tests onto master, rather than adding the tests to the branch for this PR) |
Sure. |
@fredrikekre Just to confirm this was merged - thanks for the fix 👍 |
Previously PermissionErrors where caught in the outer try in the while loop in
parse_zuliprc. This resulted in a misleading error message about invalid
credentials. This patch catches PermissionError directly at the source, and
exits directly since there is no point to keep asking the user for credentials.
In particular, when running the default docker configuration, this happens
since the zulip user in the container does not have permission to create files
in the mapped host folder. Fixes #797.