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

add better error if credentials are invalid #29719

Merged
merged 3 commits into from
Oct 8, 2021
Merged

Conversation

megan07
Copy link
Contributor

@megan07 megan07 commented Oct 7, 2021

Fixes hashicorp/terraform-provider-google#10234

ReadPathOrContents assumes if the path doesn't exist, it must be contents. But if the file just isn't where we want it, the code thinks it's the contents and proceeds. Let's verify that the credentials are valid json.

@megan07 megan07 requested a review from appilon October 8, 2021 13:39
@megan07 megan07 merged commit 71cbb2a into main Oct 8, 2021
@jkugler
Copy link

jkugler commented Oct 8, 2021

If it cannot find the file, and tries to parse the file name as JSON, it will throw this error, making the user thing the contents of the file are invalid JSON. Will this give a "file not found" error if the file does not exist?

@megan07
Copy link
Contributor Author

megan07 commented Oct 12, 2021

Hi @jkugler, I understand your concern. Unfortunately, this field allows the convenience of being a path to a file OR an intended value, and the function backend.ReadPathOrContents assumes if the file is not found, that it is the intended value. With this convenience, we lose the precise context of the error.

@jkugler
Copy link

jkugler commented Oct 12, 2021

Understood. Could the error message be changed to "Could not parse '......' as valid JSON, nor could we find a file by that name." Maybe that would help?

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2021
@xiehan xiehan deleted the megan_invalid_creds branch July 22, 2024 12:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Back end gives an extremely unhelpful error message when it can't find the credentials
3 participants