Skip to content

Commit

Permalink
Throw an exception if the creation of Bearer token fails
Browse files Browse the repository at this point in the history
  • Loading branch information
saikatsarkar056 committed Sep 11, 2024
1 parent 216a6e7 commit 18c1fa3
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.xcontent.XContentParseException;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xpack.core.common.socket.SocketAccess;
import org.elasticsearch.xpack.inference.external.request.Request;
Expand Down Expand Up @@ -55,7 +56,7 @@ static void decorateWithBearerToken(HttpPost httpPost, DefaultSecretSettings sec
return (String) map.get("access_token");
});
} catch (Exception e) {
logger.error("Failed to add Bearer token to the request");
throw new XContentParseException("Failed to add Bearer token to the request");
}

Header bearerHeader = new BasicHeader(HttpHeaders.AUTHORIZATION, "Bearer " + bearerToken);
Expand Down

0 comments on commit 18c1fa3

Please sign in to comment.