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

Custom error messages for auth error in http state backend #32264

Open
aleivag opened this issue Nov 22, 2022 · 1 comment
Open

Custom error messages for auth error in http state backend #32264

aleivag opened this issue Nov 22, 2022 · 1 comment
Labels
enhancement new new issue not yet triaged

Comments

@aleivag
Copy link

aleivag commented Nov 22, 2022

Terraform Version

Terraform v1.3.0
on linux_amd64

Use Cases

when implementing a custom http state backend, when user request to take the lock, if the backend decide the user does not have permissions, then it can return a "403 Forbidden", in that case the output the user see uts

│ Error: Error acquiring the state lock
│ 
│ Error message: HTTP remote state endpoint invalid auth
│ 
│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the "-lock=false"
│ flag, but this is not recommended.

independent of the body of the response, robing the http backend server the opportunity to provide information to the user on what to do.

Attempted Solutions

no could not find one

Proposal

I'm happy to write this, but my solution would be to on the backend code and probbaly other special casesto read the body of the response, and if the body its JSON with the field "errmsg" then display that message... if not, display the original error.

example... if the response body its:

{
   "msg": "You dont have permission to access this state file, please request it through http://bar.biz/request/tf"
}

then the display should look like

│ Error: Error acquiring the state lock

│ Error message: You dont have permission to access this state file, please request it through http://bar.biz/request/tf

│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the "-lock=false"
│ flag, but this is not recommended.

References

none that i could find

@aleivag aleivag added enhancement new new issue not yet triaged labels Nov 22, 2022
@crw
Copy link
Collaborator

crw commented Nov 23, 2022

Thanks for this feature request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants