Skip to content

Commit 5acf09d

Browse files
CID-3982: Enhance expired/wrong technical user error
1 parent ef77c00 commit 5acf09d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/kotlin/net/leanix/githubagent/config/WebSocketClientConfig.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ class WebSocketClientConfig(
2525
private val leanIXProperties: LeanIXProperties,
2626
private val gitHubEnterpriseProperties: GitHubEnterpriseProperties
2727
) {
28+
private val logger = org.slf4j.LoggerFactory.getLogger(WebSocketClientConfig::class.java)
29+
2830
@Retry(name = "ws_init_session")
2931
fun initSession(): StompSession {
3032
val headers = WebSocketHttpHeaders()
3133
val stompHeaders = StompHeaders()
32-
stompHeaders["Authorization"] = "Bearer ${leanIXAuthService.getBearerToken()}"
34+
stompHeaders["Authorization"] = runCatching {
35+
"Bearer ${leanIXAuthService.getBearerToken()}"
36+
}.getOrElse {
37+
logger.error("Failed to get Bearer token for WebSocket connection, please check your Technical User token")
38+
logger.info("Retrying to connect...")
39+
throw it
40+
}
3341
stompHeaders["GitHub-Enterprise-URL"] = gitHubEnterpriseProperties.baseUrl
3442
stompHeaders["GitHub-Agent-Version"] = GITHUB_AGENT_VERSION
3543
return stompClient().connectAsync(

0 commit comments

Comments
 (0)