Skip to content

Conversation

@samgst-amazon
Copy link
Contributor

Added a listener and changed some of the init logic to better handle auth events for emitting the token to the LSP

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@samgst-amazon samgst-amazon requested review from a team as code owners March 14, 2025 07:05
@samgst-amazon samgst-amazon changed the base branch from main to feature/q-lsp March 14, 2025 07:05
@github-actions
Copy link

Qodana Community for JVM

16 new problems were found

Inspection name Severity Problems
Unused symbol 🔶 Warning 6
Usage of redundant or deprecated syntax or deprecated symbols 🔶 Warning 4
Unstable API Usage 🔶 Warning 3
Constructor parameter is never used as a property 🔶 Warning 1
Function or property has platform type ◽️ Notice 2

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

@leigaol
Copy link
Contributor

leigaol commented Mar 14, 2025

Overall looks good!

Can you double check if this code path triggers bearer token refresh?

BearerTokenAuthState.NEEDS_REFRESH -> {
            try {
                getLogger<ToolkitAuthManager>().warn { "Starting token refresh" }
                return runUnderProgressIfNeeded(project, AwsCoreBundle.message("credentials.refreshing"), true) {
                    tokenProvider.resolveToken()
                    BearerTokenProviderListener.notifyCredUpdate(tokenProvider.id)
                    return@runUnderProgressIfNeeded false
                }

Comment on lines +65 to +69
val qConnection = ToolkitConnectionManager.getInstance(project)
.activeConnectionForFeature(QConnection.getInstance())
?: return
if (newConnection?.id != qConnection.id) return

Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking, but are we sure these lines are not duplicated? I think they already exist somewhere in CW

@samgst-amazon samgst-amazon merged commit e6d8159 into feature/q-lsp Mar 14, 2025
15 of 18 checks passed
@samgst-amazon samgst-amazon deleted the samgst/q-lsp-token-fix branch March 14, 2025 17:52
Comment on lines +82 to +85
(connection.getConnectionSettings() as? TokenConnectionSettings)
?.tokenProvider
?.delegate
?.let { it as? BearerTokenProvider }
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move this to a util

?.let { it as? BearerTokenProvider }
?.currentToken()
?.accessToken
?.let { token -> updateTokenCredentials(token, true) }
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add the var name before the boolean?

leigaol pushed a commit to leigaol/aws-toolkit-jetbrains that referenced this pull request Mar 17, 2025
leigaol pushed a commit to leigaol/aws-toolkit-jetbrains that referenced this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants