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

Warning header loses original exception when that exception contains invalid-for-netty-headers characters #2948

Open
anqit opened this issue Jul 8, 2024 · 3 comments · May be fixed by #3050
Labels
💎 Bounty bug Something isn't working

Comments

@anqit
Copy link

anqit commented Jul 8, 2024

Describe the bug
I am using zio-http and quill to build a REST service. I create a request handler via Handler.fromFunctionZIO that calls into my DB via a quill. In one instance, I forgot to lift a variable when creating the query (ie I did id == someId instead of id == lift(someId). This causes quill to throw an IllegalStateException which is then treated as a fatal defect by the quill-created (I think? I don't think that's a relevant detail) ZIO instance. With sandbox turned on for my routes, the error handling mechanism attempts to turn the error into a warning response header. However, the error text for the IllegalStateException exception has a \n character in it, which fails netty's header validation (verifyValidHeaderValueCharSequence in HttpHeaderValidationUtil.java returns the index of the first \n in the string and not -1), causing the original error to be swallowed, and the warning response header to then contain the self-fulfilling meta Schrodinger's error Validation failed for header 'warning'.

To Reproduce
Steps to reproduce the behaviour:

  1. Turn on sandbox (Server.serve(routes.sandbox))
  2. Call a route handled by a ZIO via Handler.fromFunctionZIO
  3. Have this ZIO fail fatally, and include a new line character in the exception error message

Expected behaviour
The original error is returned in the warning header.

@jdegoes
Copy link
Member

jdegoes commented Jul 30, 2024

/bounty $75 to only form proper warning headers (note that warning headers will probably be removed shortly).

Copy link

algora-pbc bot commented Jul 30, 2024

💎 $75 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #2948 with your implementation plan
  2. Submit work: Create a pull request including /claim #2948 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @uurl Aug 19, 2024, 2:59:11 AM #3033

uurl added a commit to uurl/zio-http that referenced this issue Aug 19, 2024
@uurl
Copy link

uurl commented Aug 19, 2024

/attempt #2948

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