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

Internal Auth Errors should not be Logged as Unhandled Error #7395

Open
DimuthuMadushan opened this issue Nov 21, 2024 · 1 comment
Open

Comments

@DimuthuMadushan
Copy link

Description

$subject

Currently, the service logged an unhandled error message for request with invalid credentials.

Steps to Reproduce

consider the following service with basic auth.

import ballerina/http;

type Album readonly & record {|
    string title;
    string artist;
|};

listener http:Listener securedEP = new (9090);

@http:ServiceConfig {
    auth: [
        {
            fileUserStoreConfig: {},
            scopes: ["admin"]
        }
    ]
}
service / on securedEP {

    resource function get albums() returns Album[] {
        return [
            {title: "Blue Train", artist: "John Coltrane"},
            {title: "Jeru", artist: "Gerry Mulligan"}
        ];
    }
}

When we send request with invalid credentials, it logs the following message.

curl --location --request GET 'http://localhost:9090/albums' \
--header 'Authorization: Basic YWxpYzphbGljZUAxMjM='

error message:

Running executable

error: 
        at ballerina.http.2:authenticateResource(auth_desugar.bal:45)
           dimuthu.basic_auth.0.$anonType$_1:$get$albums(service.bal:54)
time=2024-11-21T14:24:42.408+05:30 level=ERROR module=ballerina/http message="unhandled error returned from the service" error={"causes":[],"message":"","detail":{},"stackTrace":[{"callableName":"authenticateResource","moduleName":"ballerina.http.2","fileName":"auth_desugar.bal","lineNumber":45},{"callableName":"$get$albums","moduleName":"dimuthu.basic_auth.0.$anonType$_1","fileName":"service.bal","lineNumber":54}]} path="/albums" method="GET"

Version

2201.8.8, 2201.10.0

Environment Details (with versions)

No response

@TharmiganK
Copy link
Contributor

The first error log is expected:

error: 
        at ballerina.http.2:authenticateResource(auth_desugar.bal:45)
           dimuthu.basic_auth.0.$anonType$_1:$get$albums(service.bal:54)

The second log is not required since it is an internal error

@TharmiganK TharmiganK self-assigned this Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants