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 Headers Dropped on Error #572

Closed
benwis opened this issue Jul 15, 2021 · 5 comments
Closed

Custom Headers Dropped on Error #572

benwis opened this issue Jul 15, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@benwis
Copy link

benwis commented Jul 15, 2021

I'd like to add some custom headers to an Error response from a Guard, but it appears to silently drop them. It works fine when the response is not an Error. Essentially, I'm trying to return new tokens if the refresh token is valid and the access is not, and Error out.

Not sure if this is a bug or a feature request, feel free to move it.

Steps to Reproduce the Problem

  1. Use ContextBase.insert_header("test", "value");
  2. return Err("It's broken")
  3. Look at API response, the headers are not there.
  4. Return OK(()) instead, headers are set

Specifications

  • Version: 2.9.5
  • Platform: Linux
  • Subsystem: CTX/Errors
@benwis benwis added the bug Something isn't working label Jul 15, 2021
@sunli829
Copy link
Collaborator

You are right, it is indeed better to attach custom HTTP headers to the response when an error occurs.

@benwis
Copy link
Author

benwis commented Jul 15, 2021

Thanks for the commit! I updated async-graphql and async-graphql-actix-web to the latest git commit, and tested it again. It still seems like the headers are not being added, but it might not be totally fixed yet

@sunli829
Copy link
Collaborator

Sorry, I have fixed it. 🙂

@benwis
Copy link
Author

benwis commented Jul 16, 2021

No need to apologize! Headers on Errors are now working as expected! Feel free to close this issue.

Also, you should setup Github sponsor! I'd totally be willing to help fund development.

@sunli829
Copy link
Collaborator

Haha, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants