Skip to content

Conversation

@hustxiayang
Copy link
Contributor

@hustxiayang hustxiayang commented Dec 5, 2025

Description

Motivation: Users complain they just got a 500 and None when they have bugs. There is not any useful information.
Thus, instead of returning nil, I think it's better to return some useful information and valid status code to users

I updated 3 places, other places I think it's totally controlled by ai-gateway, thus I feel it's ok to still return nil:

https://github.com/envoyproxy/ai-gateway/blob/a2ba2c9ed8e7488d6fd76dbcbe08ac7008170e5d/internal/extproc/processor_impl.go#L328C15-L329C55

after discussion, this place


should still return nil too as this is not real auth

Signed-off-by: yxia216 <[email protected]>
Signed-off-by: yxia216 <[email protected]>
Signed-off-by: yxia216 <[email protected]>
@hustxiayang hustxiayang requested a review from a team as a code owner December 5, 2025 15:36
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 5, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.29%. Comparing base (932c4e2) to head (8ebc785).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1621      +/-   ##
==========================================
+ Coverage   83.26%   83.29%   +0.03%     
==========================================
  Files         137      137              
  Lines       12051    12069      +18     
==========================================
+ Hits        10034    10053      +19     
- Misses       1410     1411       +1     
+ Partials      607      605       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hustxiayang hustxiayang changed the title return user understandable response fix: return user understandable response Dec 5, 2025
@hustxiayang
Copy link
Contributor Author

/retest

Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't just return the internal error. That will expose the security risk and implementation detail. Imagine a SaaS service running this project. You have to explicitly define error type you want to return vs others.

@hustxiayang
Copy link
Contributor Author

hustxiayang commented Dec 5, 2025

@mathetake could you please tell me why it's internal error? Suppose the user's input is not valid, and can not be unmarshaled? Why we can not return the error to users? Or you just mean I should change the error message and not to include the error?

@hustxiayang hustxiayang marked this pull request as draft December 5, 2025 16:07
@yuzisun
Copy link
Contributor

yuzisun commented Dec 5, 2025

@mathetake could you please tell me why it's internal error? Suppose the user's input is not valid, and can not be unmarshaled? Why we can not return the error to users? Or you just mean I should change the error message?

@hustxiayang we need to separate out the validation errors, process body can return other internal gateway errors which should not return immediate response.

@hustxiayang hustxiayang marked this pull request as ready for review December 5, 2025 20:13
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 5, 2025
@hustxiayang
Copy link
Contributor Author

@mathetake @yuzisun Thanks a lot for your comments! This is only to return immediate response when the request is not parsable or not able to be processed. I reverted the changes in

, and make this one still return nil as this is not real auth. For other returns, they are still nil as in the description.

@hustxiayang hustxiayang changed the title fix: return user understandable response fix: return user understandable response for request parse and validation Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants