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

fix: expand home directory for credentials file #1425

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

roerohan
Copy link

Issue

The documentation for creating a tunnel's configuration file does not specify that the credentials-file field in config.yml needs to be an absolute path.

A user (E.G. me 🤦) might add a path like ~/.cloudflared/<uuid>.json and wonder why the cloudflared tunnel run command is throwing a credentials file not found error. Although one might consider it intuitive, it's not a fair assumption as a lot of CLI tools allow file paths with ~ for specifying files.

P.S. The tunnel ID in the following snippet is not a real tunnel ID, I just generated it.

url: http://localhost:8000
tunnel: 958a1ef6-ff8c-4455-825a-5aed91242135
credentials-file: ~/.cloudflared/958a1ef6-ff8c-4455-825a-5aed91242135.json

Furthermore, the error has a confusing message for the user as the file at the logged path actually exists, it is just that os.Stat failed because it could not expand the ~.

Solution

This commit fixes the above issue by running a homedir.Expand on the credentials-file path in the credentialFinder function.

The documentation does not specify that the `credentials-file` field in
`config.yaml` needs to be an absolute path. If you add a relative path
with a `~`, it throw as error that the file is not found. However, this
iis a confusing error for the user as the file at the path exists,
it is just that `os.Stat` failed because it could not expand the `~`.
This commit fixes the above issue by running a `homedir.Expand` on the
`credentials-file` path in the `credentialFinder` function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant