Skip to content

Conversation

@exigow
Copy link
Contributor

@exigow exigow commented Aug 14, 2025

Solves CON-3473

Notes:

  • I don't have a license key, so I haven't fully tested this, but looking at the TypeScript: true in the response means it's valid, and false means it's not
  • Extra: I added Try Again because I noticed that searching for the action every time the key is invalid is inconvenient
  • I wasn't sure if restarting the IDE is safe without more testing, so I ended with Restart IDE action (it was much faster to implement)

GIFs

Invalid

Peek 2025-08-15 01-24

Valid

Peek 2025-08-15 01-25


Summary by cubic

Added an "Enter Enterprise License Key" action to IntelliJ for setting and validating license keys. Users get instant feedback, with options to retry or restart the IDE as needed.

  • New Features
    • Dialog to enter and validate license key.
    • "Try again" option if key is invalid.
    • Prompt to restart IDE when key is valid.

@exigow exigow requested a review from a team as a code owner August 14, 2025 21:30
@exigow exigow requested review from tingwai and removed request for a team August 14, 2025 21:30
@exigow exigow requested review from sestinj and removed request for tingwai August 14, 2025 21:30
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 14, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

The PR adds license key functionality for the IntelliJ extension. The implementation has a critical logic error where success and error notifications are swapped, and there are several other issues including potential null pointer exceptions, missing EOF newlines, and hardcoded values that should be constants.

@github-actions
Copy link

Code Review Summary

✅ Strengths

  • UI Design: Clean implementation of a dialog for license key input with proper validation
  • User Feedback: Good use of notifications to inform users about license key validity
  • Action Flow: Proper handling of dialog exit codes and user cancellation
  • Restart Prompt: Appropriate notification about IDE restart requirement after successful license validation

⚠️ Issues Found

Critical

  • Logic Inversion Bug: The response handling logic is inverted - when isValid is true, it shows an error notification, and when false, it shows success. This will confuse users and prevent proper license activation.

High

  • Error Handling: No error handling for the messenger request. If the request fails, users get no feedback.
  • Null Safety: Multiple uses of !! operator without proper null checks, which could cause crashes.

Medium

  • Resource Management: The dialog is shown before checking if the messenger service is available, potentially confusing users if the service is unavailable.
  • Code Organization: The notification creation methods have misleading names (createSuccessAction and createErrorAction instead of createSuccessNotification and createErrorNotification).

Low

  • Import Organization: The imports could be better organized (stdlib, external libs, then internal).
  • Empty Line: Missing newline at the end of AddLicenseKey.kt file.

💡 Suggestions

  • Error Recovery: Add proper error handling for the messenger request with appropriate user feedback
  • Null Safety: Replace !! with safe calls and proper null handling
  • Testing: Consider adding unit tests for the license validation logic
  • Documentation: Add KDoc comments to public classes and methods explaining their purpose
  • Constants: Consider extracting notification messages to constants for easier maintenance and potential localization

🚀 Overall Assessment

REQUEST_CHANGES

The implementation has a critical bug in the response handling logic that must be fixed before merging. The inverted boolean check will cause the application to show success when the license is invalid and vice versa. Additionally, the lack of error handling could lead to poor user experience when network issues occur.

@exigow
Copy link
Contributor Author

exigow commented Aug 14, 2025

@sestinj, I've decided to end with Restart IDE just so we can ship this quickly (I'm absent tomorrow), but we can think next week about improving that.

@exigow exigow marked this pull request as draft August 14, 2025 21:33
@exigow
Copy link
Contributor Author

exigow commented Aug 14, 2025

I fixed a few things. The bot caught a few potential problems.

@exigow exigow marked this pull request as ready for review August 14, 2025 21:40
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR adds license key functionality to the IntelliJ extension. The implementation has several issues that need attention, including missing error handling, potential NPE risks, lack of input validation, and missing newlines at EOF.

@github-actions
Copy link

Code Review Summary

✅ Strengths

  • Clean Architecture: The code follows a clear separation of concerns with the action class handling the workflow and a separate dialog class for UI
  • Error Handling: Good implementation of success/error notifications with appropriate user feedback
  • Async Processing: Proper use of messenger callbacks for asynchronous license validation
  • User Experience: Thoughtful UX with ability to retry on failure and prompt for IDE restart on success
  • Validation: Input validation in the dialog ensures license key is not empty

⚠️ Issues Found

Medium

  • Missing XML Configuration: The new action AddLicenseKey is not registered in plugin.xml. IntelliJ actions must be registered to be accessible in the IDE
  • Error Recovery: The messenger request doesn't handle network failures or null responses gracefully
  • Thread Safety: UI updates from the messenger callback should be dispatched to the EDT (Event Dispatch Thread)

Low

  • Code Duplication: The ActionEvent recreation in the retry logic could be simplified
  • Magic Strings: The MDM endpoint path "mdm/setLicenseKey" could be extracted as a constant
  • Input Sanitization: No trimming of whitespace from the license key input

💡 Suggestions

  • Add Action Registration: Register the AddLicenseKey action in plugin.xml with appropriate menu placement and keyboard shortcut
  • Improve Error Handling: Add try-catch blocks around the messenger request and handle potential exceptions
  • EDT Safety: Wrap notification calls in ApplicationManager.getApplication().invokeLater() when called from background threads
  • Extract Constants: Define constants for notification group name and MDM endpoints
  • Add Logging: Include debug logging for troubleshooting license validation issues
  • Input Enhancement: Add copy/paste support and consider masking the license key input for security

🚀 Overall Assessment

REQUEST_CHANGES

The implementation is well-structured but needs the action registration in plugin.xml to be functional. Additionally, the thread safety issues should be addressed before merging to prevent potential UI freezes or exceptions.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Aug 14, 2025
@Patrick-Erichsen Patrick-Erichsen merged commit 103a98c into main Aug 14, 2025
45 checks passed
@Patrick-Erichsen Patrick-Erichsen deleted the exigow/enter-license branch August 14, 2025 21:51
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Aug 14, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 14, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 14, 2025
exigow added 3 commits August 15, 2025 01:26
Solves CON-3473

Notes:
* I don't have a license key, so I haven't fully tested this, but looking at the TypeScript: true in the response means it's valid, and false means it's not
* Extra: I added Try Again because I noticed that searching for the action every time the key is invalid is inconvenient
* I wasn't sure if restarting the IDE is safe without more testing, so I ended with Restart IDE action (it was much faster to implement)
@sestinj
Copy link
Contributor

sestinj commented Aug 18, 2025

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor

sestinj commented Aug 18, 2025

🎉 This PR is included in version 1.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer released size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants