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

Fix error logging logic with interceptors #1846

Merged
merged 23 commits into from
Feb 1, 2024

Conversation

TharmiganK
Copy link
Contributor

@TharmiganK TharmiganK commented Jan 29, 2024

Purpose

$Subject

Fixes: ballerina-platform/ballerina-library#5877

  • The unhandled internal errors such as dispatching errors, data-binding errors, data-validation errors and transport level errors will be printed at the native level
error: no header value found for 'foo'

error: header binding failed for parameter: 'id'
cause: error occurred while converting "hello" to the target type

error: no matching resource found for path : /api/path, method : GET
  • The other unhandled errors returned from the resource will be logged using ballerina/log:printError method at the default error interceptor
time=2024-01-29T10:18:11.872+05:30 level=ERROR module=ballerina/http message="unhandled error
 returned from the service" error={"causes":[],"message":"Simulated error","detail":{},"stackTrace":
[{"callableName":"getError","moduleName":"ballerina.http_misc_tests$test.2.tests.http_resource_
function_return_test","fileName":"tests/http_resource_function_return_test.bal","lineNumber":54},
{"callableName":"$default$checkErrorReturn","moduleName":"ballerina.http_misc_tests$test.2.
$anonType$_51","fileName":"tests/http_resource_function_return_test.bal","lineNumber":38}]} 
path="/checkErrorReturn" method="GET"
  • The above applies to status code errors as well
time=2024-01-29T10:15:08.976+05:30 level=ERROR module=ballerina/http message="unhandled error
 returned from the service" error={"causes":[],"message":"Album not found","detail":{"body":{
"timeStamp":"2024-01-29T04:45:08.939823Z","message":"Album not found for title: test"}},
"stackTrace":[{"callableName":"$get$albums$^","moduleName":"tharmigan.intercept_error.0.$anonType$_0",
"fileName":"main.bal","lineNumber":37}]} path="/albums/test" method="GET"

Examples

N/A

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests (Testing is done manually as the fix is related to logs)
  • Updated the spec
  • Checked native-image compatibility

Copy link

codecov bot commented Jan 29, 2024

Codecov Report

Attention: 18 lines in your changes are missing coverage. Please review.

Comparison is base (74ea7f2) 81.33% compared to head (0aa0a21) 81.64%.

Files Patch % Lines
.../stdlib/http/api/service/signature/ParamUtils.java 66.66% 6 Missing ⚠️
...a/io/ballerina/stdlib/http/api/HttpDispatcher.java 62.50% 3 Missing ⚠️
...ib/http/api/service/signature/AllHeaderParams.java 85.71% 2 Missing ⚠️
...tdlib/http/api/service/signature/PayloadParam.java 50.00% 1 Missing and 1 partial ⚠️
...tdlib/http/api/BallerinaHTTPConnectorListener.java 75.00% 1 Missing ⚠️
...b/http/api/HttpRequestInterceptorUnitCallback.java 87.50% 1 Missing ⚠️
.../ballerina/stdlib/http/api/ResourceDispatcher.java 83.33% 1 Missing ⚠️
...dlib/http/api/nativeimpl/ExternRequestContext.java 66.66% 1 Missing ⚠️
...dlib/http/transport/message/HttpCarbonMessage.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1846      +/-   ##
============================================
+ Coverage     81.33%   81.64%   +0.31%     
- Complexity        0      562     +562     
============================================
  Files           357      393      +36     
  Lines         19751    21502    +1751     
  Branches       4451     4799     +348     
============================================
+ Hits          16064    17555    +1491     
- Misses         2830     2957     +127     
- Partials        857      990     +133     

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

@TharmiganK TharmiganK marked this pull request as ready for review January 30, 2024 13:29
dilanSachi
dilanSachi previously approved these changes Feb 1, 2024
Copy link
Contributor

@dilanSachi dilanSachi left a comment

Choose a reason for hiding this comment

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

LGTM

@TharmiganK TharmiganK added the Skip GraalVM Check This will skip the GraalVM compatibility check label Feb 1, 2024
Copy link

sonarqubecloud bot commented Feb 1, 2024

Quality Gate Failed Quality Gate failed

Failed conditions

12.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@TharmiganK TharmiganK merged commit ac0c0b7 into master Feb 1, 2024
7 of 8 checks passed
@TharmiganK TharmiganK deleted the fix-interceptor-error-logs branch February 1, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip GraalVM Check This will skip the GraalVM compatibility check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Response interceptors print stack trace even when handling the error correctly
2 participants