ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.28k stars 1.63k forks source link

Logging bug in `HttpRequesterMiddleware` #1953

Closed masoud-bahrami closed 5 months ago

masoud-bahrami commented 6 months ago

BadRequest should be logged as debug!

Update by Maintainer on Feb 27, 2024

BadRequest should be logged as warning via LogWarning method.

raman-m commented 6 months ago

@masoud-bahrami Now Masoud, please explain what did you do in this PR? I see a small refactoring here... Nothing more!

Have you read our development process docs?

masoud-bahrami commented 6 months ago

@raman-m In the CreateLogBasedOnResponse method due to if (response.Data?.StatusCode <= HttpStatusCode.BadRequest) logic, BadRequest will be logged as Information.

As you can see, In the next branch of if, else if (response.Data?.StatusCode >= HttpStatusCode.BadRequest) again HttpStatusCode.BadRequest is checked.

It's like If (a <= 400) do something else If (a >= 400) do something else

raman-m commented 6 months ago

@masoud-bahrami

BadRequest should be logged as debug!

Did you mean as warning? 😉 to be logged by LogWarning method? OK... Now I see!.. It is a small comparison typo <= in the code but resulting to real bug...

raman-m commented 6 months ago

@ggnaegi Tom is the author of this tiny ugly bug in commit https://github.com/ThreeMammals/Ocelot/commit/ebe662abe6b04ab35a13f3936440aa6904a5fa4d 🤣 added in version 14.0.3 Please review! I will ask unit & acceptance tests...