You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by cs...@apache.org on 2026/10/06 14:10:30 UTC
(impala) 02/02: IMPALA-15412: Fix Formatting of error_description in WWW-Authenticate Header
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit d6638f0d9ea2b66f18cbf76e3c25c59026b9851d
Author: jasonmfehr <jf...@cloudera.com>
AuthorDate: Wed Sep 23 08:50:08 2026 -0700
IMPALA-15412: Fix Formatting of error_description in WWW-Authenticate Header
Removes the extra trailing newline and space in the error_description
key-value part of the WWW-Authenticate http header. This header is
returned when JWT/OAuth auth fails.
Testing accomplished by manually verifing the WWW-Authenticate http
header value using curl and by existing JWT/OAuth custom cluster
tests passing.
Change-Id: Ifbb593c82afca89394560d21c5ad9a5c49ad2a53
Assisted-by: GPT-5.3-Codex (Copilot)
Reviewed-on: http://gerrit.cloudera.org:8080/24929
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Michael Smith <mi...@cloudera.com>
---
be/src/util/oauth-servers-manager-test.cc | 15 +++++++++++++++
be/src/util/oauth-servers-manager.cc | 9 +++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/be/src/util/oauth-servers-manager-test.cc b/be/src/util/oauth-servers-manager-test.cc
index 9c2b13e7f..5d18a8484 100644
--- a/be/src/util/oauth-servers-manager-test.cc
+++ b/be/src/util/oauth-servers-manager-test.cc
@@ -144,4 +144,19 @@ TEST(OAuthServersManagerTest, VerifyFailsWhenOnlyWrongJwksConfigured) {
EXPECT_NE(string::npos, status.GetDetail().find("no matching key"));
}
+TEST(OAuthServersManagerTest, AuthFailMessageRemovesTrailingCrLf) {
+ OAuthServersManager fixture;
+ Status stat("error message\n\r");
+ EXPECT_EQ("WWW-Authenticate: Bearer error=\"invalid_token\","
+ "error_description=\"error message\"",
+ OAuthServersManager::BearerAuthFailureHeader(stat));
+}
+
+TEST(OAuthServersManagerTest, AuthFailMessageEmpty) {
+ OAuthServersManager fixture;
+ Status stat("");
+ EXPECT_EQ("WWW-Authenticate: Bearer error=\"invalid_token\"," "error_description=\"\"",
+ OAuthServersManager::BearerAuthFailureHeader(stat));
+}
+
} // namespace impala
diff --git a/be/src/util/oauth-servers-manager.cc b/be/src/util/oauth-servers-manager.cc
index 9a5e72e21..176f37305 100644
--- a/be/src/util/oauth-servers-manager.cc
+++ b/be/src/util/oauth-servers-manager.cc
@@ -17,6 +17,7 @@
#include "util/oauth-servers-manager.h"
+#include "common/compiler-util.h"
#include "common/logging.h"
#include "gutil/strings/substitute.h"
#include "util/oauth-server-config.h"
@@ -28,10 +29,14 @@ using namespace strings;
namespace impala {
string OAuthServersManager::BearerAuthFailureHeader(const Status& status) {
- const string error_message =
+ string error_message =
status.GetDetail().empty() ? status.msg().msg() : status.GetDetail();
+ while (!error_message.empty() && (error_message.back() == '\n'
+ || UNLIKELY(error_message.back() == '\r'))) {
+ error_message.pop_back();
+ }
return Substitute("WWW-Authenticate: Bearer error=\"invalid_token\","
- "error_description=\"$0 \"", error_message);
+ "error_description=\"$0\"", error_message);
}
Status OAuthServersManager::Init() {