Skip to content

fix: show warning notification instead of silently failing when report save directory is invalid#247

Merged
soul2zimate merged 2 commits into
redhat-developer:mainfrom
soul2zimate:TC-3902
Mar 27, 2026
Merged

fix: show warning notification instead of silently failing when report save directory is invalid#247
soul2zimate merged 2 commits into
redhat-developer:mainfrom
soul2zimate:TC-3902

Conversation

@soul2zimate

Copy link
Copy Markdown
Contributor

fix: show warning notification instead of silently failing when report save directory is invalid

Replace auto-creation of missing directories with existence validation and user-visible balloon notifications for all failure scenarios (missing directory, not a directory, IO errors).

Jira: https://redhat.atlassian.net/browse/TC-3902

…t save directory is invalid

Replace auto-creation of missing directories with existence validation and
user-visible balloon notifications for all failure scenarios (missing directory,
not a directory, IO errors).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Show warning notifications for invalid report save directories

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Replace auto-creation of missing directories with validation checks
• Show warning notifications for invalid report save directories
• Display user-friendly error messages for IO failures
• Register notification group in plugin configuration
Diagram
flowchart LR
  A["Report Save Triggered"] --> B["Validate Directory Exists"]
  B -->|Not Exists| C["Show Warning Notification"]
  B -->|Exists| D["Check if Directory"]
  D -->|Not Directory| E["Show Warning Notification"]
  D -->|Is Directory| F["Copy Report File"]
  F -->|IO Error| G["Show Error Notification"]
  F -->|Success| H["Log Success"]
  C --> I["Return"]
  E --> I
  G --> I
Loading

Grey Divider

File Changes

1. src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java 🐞 Bug fix +47/-2

Add validation and user notifications for report save

• Added imports for IntelliJ notification APIs
• Replaced Files.createDirectories() with existence and type validation checks
• Added warning notifications for missing directories and non-directory paths
• Added error notifications for IOException and unexpected exceptions
• Each validation failure now displays user-friendly balloon notifications with actionable guidance

src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java


2. src/main/resources/META-INF/plugin.xml ⚙️ Configuration changes +1/-0

Register notification group in plugin configuration

• Registered new notification group "Red Hat Dependency Analytics" with BALLOON display type
• Enables the plugin to display user-visible warning and error notifications

src/main/resources/META-INF/plugin.xml


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Mar 27, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider


Action required

1. Files.isWritable check missing📎 Requirement gap ⛯ Reliability
Description
The updated logic validates existence and directory-ness, but does not explicitly validate that the
configured directory is writable before attempting the copy. This can lead to unclear user feedback
for permission failures, contrary to the requirement to explicitly indicate the save directory is
unwritable/not accessible.
Code

src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[R67-82]

+                if (!Files.isDirectory(targetDir)) {
+                    String message = "Report save path is not a directory: " + targetDir;
+                    LOG.warn(message);
+                    NotificationGroupManager.getInstance()
+                            .getNotificationGroup(NOTIFICATION_GROUP_ID)
+                            .createNotification(
+                                    "Dependency Analytics Report",
+                                    message + ". Please update the path in Settings > Tools > Red Hat Dependency Analytics.",
+                                    NotificationType.WARNING
+                            )
+                            .notify(null);
+                    return;
+                }

                String timestamp = LocalDateTime.now().format(TIMESTAMP_FORMAT);
                String filename = String.format("report_%s_%s.html", manifestName, timestamp);
Evidence
PR Compliance ID 1 requires an explicit user-facing error when the configured directory lacks write
permissions; the added code checks only Files.exists and Files.isDirectory and then proceeds to
Files.copy without a pre-check such as Files.isWritable(targetDir) to generate a clear
unwritable-path message.

Show an error when IntelliJ plugin report save directory path is invalid or not writable
src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[67-86]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The code does not explicitly validate that the configured save directory is writable, which can prevent a clear, user-directed message for permission-denied scenarios.

## Issue Context
Compliance requires a clear user-facing error when the configured report save directory is not writable.

## Fix Focus Areas
- src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[67-96]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. NotificationType.WARNING used for errors📎 Requirement gap ✓ Correctness
Description
The new user-facing notifications for an invalid report save directory are emitted as warnings
rather than explicit errors. This does not meet the requirement to show an explicit error when the
configured save directory is invalid/unreachable.
Code

src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[R56-63]

+                    NotificationGroupManager.getInstance()
+                            .getNotificationGroup(NOTIFICATION_GROUP_ID)
+                            .createNotification(
+                                    "Dependency Analytics Report",
+                                    message + ". Please create the directory or update the path in Settings > Tools > Red Hat Dependency Analytics.",
+                                    NotificationType.WARNING
+                            )
+                            .notify(null);
Evidence
PR Compliance ID 1 requires an explicit user-facing error for an invalid/unreachable save directory;
the added notification for the invalid directory path uses NotificationType.WARNING instead of an
error severity.

Show an error when IntelliJ plugin report save directory path is invalid or not writable
src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[56-63]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Notifications shown for invalid/unreachable report save directory are emitted as `NotificationType.WARNING`, but the requirement is to show an explicit error to the user.

## Issue Context
This impacts all failure scenarios for the configured “Reports > Save Directory” path (invalid path / unreachable / permissions).

## Fix Focus Areas
- src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[53-106]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Unscoped notifications🐞 Bug ✧ Quality
Description
ReportFileManager.saveReportCopy calls Notification.notify(null), so warnings/errors are not
associated with the Project that initiated the report save and may show in the wrong IDE window.
AnalyticsReportUtils.openCustomEditor has the Project context but does not pass it through, making
the new error reporting unreliable in multi-project sessions.
Code

src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[R56-64]

+                    NotificationGroupManager.getInstance()
+                            .getNotificationGroup(NOTIFICATION_GROUP_ID)
+                            .createNotification(
+                                    "Dependency Analytics Report",
+                                    message + ". Please create the directory or update the path in Settings > Tools > Red Hat Dependency Analytics.",
+                                    NotificationType.WARNING
+                            )
+                            .notify(null);
+                    return;
Evidence
All new notifications in saveReportCopy are delivered with notify(null), which drops project
scoping. The only call site for saveReportCopy is AnalyticsReportUtils.openCustomEditor, which
already receives a Project but currently calls saveReportCopy without passing it, so
ReportFileManager cannot scope notifications correctly.

src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[48-107]
src/main/java/org/jboss/tools/intellij/report/AnalyticsReportUtils.java[50-75]
src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[53-79]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ReportFileManager.saveReportCopy` posts notifications using `.notify(null)`, which makes them unscoped. Since the caller already has a `Project`, notifications should be associated with that project so users reliably see warnings/errors in the correct IDE window.

### Issue Context
`AnalyticsReportUtils.openCustomEditor(...)` receives a `Project project` and triggers `saveReportCopy(...)`, but the `Project` context is currently dropped.

### Fix Focus Areas
- Update method signature to accept `Project` (nullable if needed) and use it in `.notify(project)`
 - src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java[39-107]
- Pass the project from the call site
 - src/main/java/org/jboss/tools/intellij/report/AnalyticsReportUtils.java[66-74]

### Implementation notes
- Consider guarding against disposed projects before notifying (e.g., `project == null || project.isDisposed()` → notify with `null` or skip).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment thread src/main/java/org/jboss/tools/intellij/report/ReportFileManager.java Outdated
- Add Project parameter to ReportFileManager.saveReportCopy for scoped notifications
- Add writable directory validation with user-facing error
- Change all notification types from WARNING to ERROR
- Guard against disposed projects before notifying

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@soul2zimate
soul2zimate merged commit dea21cb into redhat-developer:main Mar 27, 2026
7 checks passed
@soul2zimate
soul2zimate deleted the TC-3902 branch March 27, 2026 00:41
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.

1 participant