Skip to content

Conversation

@alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Aug 27, 2025

Description

The idea is to create a bug report accumulating all the things required into a compressed archive that user can then upload to the github. Please see if anyother information you think is required
This should also be workable with v4.00 when that branch is updated with master to also get the EIM logs, you will still get the EIM logs if you are using it in your system

The PR for v4.0 release is here (#1306)

Fixes # (IEP-1618)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Try to verify the logs file in the generated bug report by going to espressif menu and clicking generate bug report

Test Configuration:

  • ESP-IDF Version: any
  • OS (Windows,Linux and macOS): all

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features

    • Adds a “Generate Bug Report” command to the ESP‑IDF menu that collects system/IDE info, logs, and bundles them into a timestamped ZIP in your workspace.
    • The IDE prints the generated ZIP path to the console and opens your browser to pre-fill a new GitHub issue using the bug-report template.
  • Documentation

    • Bug report guidance updated to ask users to attach the generated ZIP via “Espressif > Generate Bug Report.”

@alirana01 alirana01 self-assigned this Aug 27, 2025
Copy link
Collaborator Author

@alirana01 alirana01 left a comment

Choose a reason for hiding this comment

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

Self Review

@coderabbitai

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

*/
public class BugReportGenerator
{
private static final String bugReportDirectoryPrefix = "bug_report_"; //$NON-NLS-1$
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: the naming convention for a final static field is all uppercase letters with underscores separating words.

Comment on lines 124 to 127
String osName = System.getProperty("os.name", "Unknown"); //$NON-NLS-1$ //$NON-NLS-2$
String osVersion = System.getProperty("os.version", "Unknown"); //$NON-NLS-1$ //$NON-NLS-2$
String arch = System.getProperty("os.arch", "Unknown"); //$NON-NLS-1$//$NON-NLS-2$

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we can use a variable here for "Unknown"

String r1 = base.relativize(p1).toString().replace(File.separatorChar, '/');
String r2 = base.relativize(p2).toString().replace(File.separatorChar, '/');
return r1.compareTo(r2);
}).collect(Collectors.toList());
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we can use Stream.toList()

@alirana01 alirana01 requested a review from sigmaaa September 1, 2025 13:16
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/FileUtil.java (1)

416-425: Fix param typo, ensure parent dirs exist, and write with UTF‑8 (no platform default).

The method uses a misspelled parameter, doesn’t ensure directories exist, and writes with platform encoding. This can fail on first run and corrupt non‑ASCII content.

-    public static File createFileWithContentsInDirectory(String fileName, String content, String direcotry) throws IOException
-    {
-        java.nio.file.Path directoryPath = java.nio.file.Paths.get(direcotry);
-        java.nio.file.Path filePath = directoryPath.resolve(fileName);
-        try (FileWriter writer = new FileWriter(filePath.toFile()))
-        {
-            writer.write(content);
-        }
-        return filePath.toFile();
-    }
+    public static File createFileWithContentsInDirectory(String fileName, String content, String directory) throws IOException
+    {
+        java.nio.file.Path directoryPath = java.nio.file.Paths.get(directory);
+        java.nio.file.Path filePath = directoryPath.resolve(fileName);
+        // Ensure all parent directories exist (handles fileName with subdirs too)
+        java.nio.file.Files.createDirectories(filePath.getParent());
+        try (java.io.BufferedWriter writer =
+                java.nio.file.Files.newBufferedWriter(
+                    filePath,
+                    java.nio.charset.StandardCharsets.UTF_8,
+                    java.nio.file.StandardOpenOption.CREATE,
+                    java.nio.file.StandardOpenOption.TRUNCATE_EXISTING))
+        {
+            writer.write(content != null ? content : "");
+        }
+        return filePath.toFile();
+    }

Add imports if not already present (see earlier import diff).

🧹 Nitpick comments (2)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/FileUtil.java (2)

11-25: Switch to NIO writer + UTF-8; adjust imports and drop FileWriter.

Moving createFileWithContentsInDirectory to Files.newBufferedWriter(..., StandardCharsets.UTF_8, ...) avoids platform-default encodings and aligns with the rest of the class’ NIO usage. Remove FileWriter and add the needed imports.

-import java.io.FileWriter;
+import java.io.BufferedWriter;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.StandardOpenOption;

352-361: Close Scanner with try‑with‑resources; prefer System.lineSeparator().

Prevents a resource leak if an exception is thrown mid‑loop and clarifies the line separator.

-        try
-        {
-            Scanner scanner = new Scanner(new File(absoluteFilePath));
-            while (scanner.hasNext())
-            {
-                fileContents.append(scanner.nextLine());
-                fileContents.append(System.getProperty("line.separator")); //$NON-NLS-1$
-            }
-            scanner.close();
-        }
+        try (Scanner scanner = new Scanner(new File(absoluteFilePath), UTF_8))
+        {
+            while (scanner.hasNextLine())
+            {
+                fileContents.append(scanner.nextLine())
+                             .append(System.lineSeparator());
+            }
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b5d8352 and af740f7.

📒 Files selected for processing (2)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (1 hunks)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/FileUtil.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
🔇 Additional comments (2)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/FileUtil.java (2)

427-491: LGTM: robust, ordered zipping with preserved timestamps.

Good use of Files.walk, stable ordering (dirs first), explicit root entry, and try‑with‑resources. This underpins the bug‑report feature well.


434-437: Apply directory-guard and force UTF-8 (plugin targets JavaSE-17)

  • After
        Path base = directoryToZip.toPath();
        Path zipPath = Paths.get(zipFileName);
    insert
        // Prevent placing the ZIP inside the source directory
        Path absBase = base.toAbsolutePath();
        Path absZip  = zipPath.toAbsolutePath();
        if (absZip.startsWith(absBase)) {
            throw new IllegalArgumentException("zipFileName must not be inside directoryToZip");
        }
  • Update the ZipOutputStream ctor at line 457 to
  • try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(zipPath)))
  • try (ZipOutputStream zos = new ZipOutputStream(
  •     Files.newOutputStream(zipPath), StandardCharsets.UTF_8))
    
  • Add import:
    import java.nio.charset.StandardCharsets;

Copy link
Collaborator

@sigmaaa sigmaaa left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

Hi @alirana01 , thanks for the PR - this is really helpful for troubleshooting purposes.

I noticed that we're uploading the entire .metadata folder from the workspace. This folder is usually large and contains a lot of additional information about plugins. What we probably need is only the .metadata/.log file.

It would be great if you could incorporate this change. Otherwise, it looks good to me.

@alirana01
Copy link
Collaborator Author

Hi @alirana01 , thanks for the PR - this is really helpful for troubleshooting purposes.

I noticed that we're uploading the entire .metadata folder from the workspace. This folder is usually large and contains a lot of additional information about plugins. What we probably need is only the .metadata/.log file.

It would be great if you could incorporate this change. Otherwise, it looks good to me.

Hi @kolipakakondal
Thanks for the feedback I have updated it to now only add .log file and also any older log files that are for the same day or a day older so we dont miss any critical information in those backed up log files.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (2)

87-93: Fix Windows EIM logs path: use LOCALAPPDATA (not APPDATA) and drop '\Local'.

APPDATA points to Roaming; the logs live under Local. Use LOCALAPPDATA and construct "...\eim\logs".

-        case Platform.OS_WIN32:
-            eimPath = System.getenv("APPDATA"); //$NON-NLS-1$
-            if (!StringUtil.isEmpty(eimPath))
-            {
-                eimPath = eimPath + "\\Local\\eim\\logs"; //$NON-NLS-1$
-            }
+        case Platform.OS_WIN32:
+            eimPath = System.getenv("LOCALAPPDATA"); //$NON-NLS-1$
+            if (!StringUtil.isEmpty(eimPath))
+            {
+                eimPath = eimPath + "\\eim\\logs"; //$NON-NLS-1$
+            }

193-195: Compile fix: use OperatingSystemMXBean physical memory APIs.

-            freePhys = osBean.getFreeMemorySize();
-            totalPhys = osBean.getTotalMemorySize();
+            freePhys = osBean.getFreePhysicalMemorySize();
+            totalPhys = osBean.getTotalPhysicalMemorySize();
🧹 Nitpick comments (4)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (4)

262-266: Remove unused filesToZip list.

Not used; dead code.

-            List<File> filesToZip = new LinkedList<>();
-            filesToZip.add(installedToolsFile);
-            filesToZip.add(productInfoFile);
-            filesToZip.add(basicSysInfoFile);

77-79: Minor: avoid trailing separator in directory path.

Cleaner and cross-platform.

-        String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")); //$NON-NLS-1$
-        bugReportDirectory = getWorkspaceDirectory().resolve(BUG_REPORT_DIRECTORY_PREFIX + timestamp + File.separator)
-                .toFile();
+        String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")); //$NON-NLS-1$
+        bugReportDirectory = getWorkspaceDirectory().resolve(BUG_REPORT_DIRECTORY_PREFIX + timestamp).toFile();

268-276: Prefer File(parent, child) and tidy NLS comments.

Reduces string concat and fixes stray ')' in the comment.

-            File ideLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "ide_metadata_logs"); //$NON-NLS-1$ )
+            File ideLogDir = new File(bugReportDirectory, "ide_metadata_logs"); //$NON-NLS-1$
-            File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$ )
+            File eimLogDir = new File(bugReportDirectory, "eim_logs"); //$NON-NLS-1$

Also applies to: 279-281


101-107: Confirm Linux EIM logs location and consider checking both candidates.

Path currently uses "/.local/share/.eim/logs"; some installs use "/.local/share/eim/logs". Recommend probing both and returning null if neither exists.

-        case Platform.OS_LINUX:
-            eimPath = System.getProperty("user.home"); //$NON-NLS-1$
-            if (!StringUtil.isEmpty(eimPath))
-            {
-                eimPath = eimPath + "/.local/share/.eim/logs"; //$NON-NLS-1$
-            }
+        case Platform.OS_LINUX:
+            String home = System.getProperty("user.home"); //$NON-NLS-1$
+            if (!StringUtil.isEmpty(home)) {
+                String[] candidates = {
+                    home + "/.local/share/eim/logs", //$NON-NLS-1$
+                    home + "/.local/share/.eim/logs" //$NON-NLS-1$
+                };
+                for (String c : candidates) {
+                    if (new File(c).exists()) { eimPath = c; break; }
+                }
+            }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between af740f7 and 4f0658b.

📒 Files selected for processing (1)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (3)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/logging/Logger.java (1)
  • Logger (21-137)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/FileUtil.java (1)
  • FileUtil (48-493)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/StringUtil.java (1)
  • StringUtil (11-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_macos
🔇 Additional comments (1)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (1)

122-179: IDE metadata logs selection looks good.

Whitelisting .log (today/prev-day) and version.ini mitigates PII risk vs copying entire .metadata.

Comment on lines +112 to +113
return new File(eimPath);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Prevent catastrophic copy when EIM path is missing.

getEimLogPath() returns new File("") on empty, which resolves to the CWD; copyDirectory would then copy the whole working dir. Return null when unresolved and guard the copy.

-        return new File(eimPath);
+        if (StringUtil.isEmpty(eimPath)) {
+            return null;
+        }
+        return new File(eimPath);
-        File eimLogPath = getEimLogPath();
-        File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$ )
-        FileUtil.copyDirectory(eimLogPath, eimLogDir);
+        File eimLogPath = getEimLogPath();
+        if (eimLogPath != null && eimLogPath.exists() && eimLogPath.isDirectory()) {
+            File eimLogDir = new File(bugReportDirectory, "eim_logs"); //$NON-NLS-1$
+            FileUtil.copyDirectory(eimLogPath, eimLogDir);
+        }

Also applies to: 279-282

🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around lines 112-113 (and likewise around 279-282), getEimLogPath() currently
returns new File("") when the EIM path is empty which resolves to the CWD and
can cause copyDirectory to copy the whole working directory; change
getEimLogPath() to return null when the path is empty/unresolved and update the
callers to guard before copying (skip the copy and log a warning or handle
absence) so copyDirectory is only invoked with a non-null, valid directory File.

Comment on lines 254 to 260
try
{
File installedToolsFile = FileUtil.createFileWithContentsInDirectory("installed_tools.txt", //$NON-NLS-1$
installedToolsCommandOutput, bugReportDirectory.getAbsolutePath());
File productInfoFile = FileUtil.createFileWithContentsInDirectory("product_information.txt", //$NON-NLS-1$
productInformationCommandOutput, bugReportDirectory.getAbsolutePath());
File basicSysInfoFile = createBasicSystemInfoFile();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Null-safe file writes for command outputs.

Avoid NPE if either output is null.

-            File installedToolsFile = FileUtil.createFileWithContentsInDirectory("installed_tools.txt", //$NON-NLS-1$
-                    installedToolsCommandOutput, bugReportDirectory.getAbsolutePath());
-            File productInfoFile = FileUtil.createFileWithContentsInDirectory("product_information.txt", //$NON-NLS-1$
-                    productInformationCommandOutput, bugReportDirectory.getAbsolutePath());
+            String installedToolsOut = installedToolsCommandOutput == null ? StringUtil.EMPTY : installedToolsCommandOutput;
+            String productInfoOut = productInformationCommandOutput == null ? StringUtil.EMPTY : productInformationCommandOutput;
+            File installedToolsFile = FileUtil.createFileWithContentsInDirectory("installed_tools.txt", //$NON-NLS-1$
+                    installedToolsOut, bugReportDirectory.getAbsolutePath());
+            File productInfoFile = FileUtil.createFileWithContentsInDirectory("product_information.txt", //$NON-NLS-1$
+                    productInfoOut, bugReportDirectory.getAbsolutePath());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try
{
File installedToolsFile = FileUtil.createFileWithContentsInDirectory("installed_tools.txt", //$NON-NLS-1$
installedToolsCommandOutput, bugReportDirectory.getAbsolutePath());
File productInfoFile = FileUtil.createFileWithContentsInDirectory("product_information.txt", //$NON-NLS-1$
productInformationCommandOutput, bugReportDirectory.getAbsolutePath());
File basicSysInfoFile = createBasicSystemInfoFile();
try
{
// Null-safe command outputs to avoid passing null into the file-creation utility
String installedToolsOut = installedToolsCommandOutput == null
? StringUtil.EMPTY
: installedToolsCommandOutput;
String productInfoOut = productInformationCommandOutput == null
? StringUtil.EMPTY
: productInformationCommandOutput;
File installedToolsFile = FileUtil.createFileWithContentsInDirectory(
"installed_tools.txt", //$NON-NLS-1$
installedToolsOut,
bugReportDirectory.getAbsolutePath());
File productInfoFile = FileUtil.createFileWithContentsInDirectory(
"product_information.txt", //$NON-NLS-1$
productInfoOut,
bugReportDirectory.getAbsolutePath());
File basicSysInfoFile = createBasicSystemInfoFile();
🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around lines 254 to 260, the code calls
FileUtil.createFileWithContentsInDirectory using installedToolsCommandOutput and
productInformationCommandOutput which can be null and cause an NPE; fix by
ensuring null-safe values before calling the method (e.g., replace nulls with
empty strings or only create the file when the output is non-null). Concretely,
compute safe strings like String installedTools = installedToolsCommandOutput ==
null ? "" : installedToolsCommandOutput and String productInfo =
productInformationCommandOutput == null ? "" : productInformationCommandOutput,
then pass those safe values to createFileWithContentsInDirectory (or skip file
creation when you prefer) so no NPE occurs.

Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM

@AndriiFilippov
Copy link
Collaborator

AndriiFilippov commented Sep 9, 2025

@alirana01 hi!

Tested under:
OS - Windows 11
ESP-IDF: v5.5

If the problem occurs during the ESP-IDF tools installation, clicking "Generate Bug Report" brings up a pop-up asking to install and configure the IDF.
image

Does this mean that "Generate Bug Report" doesn't provide any details about issues during the tools installation process?

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi!

Tested under:
OS - Windows 11
ESP-IDF: v5.5

Install tools -> execute "Generate Bug Report" :

  1. after bug report has been generated the console output looks fine:
================================
Bug report completed. You can find the report at: C:\Users\andri\workspaceBugReport\bug_report_20250909_124336.zip 
=================================


Opening browser to create a new issue...

but error occurs in Error log Command 'com.espressif.idf.ui.command.generateBugReport' failed

error.log

@AndriiFilippov
Copy link
Collaborator

  1. the ZIP file been generated but workspace contains 2 folders, zipped and unzipped:
image

Is it how it's supposed to be?

@AndriiFilippov
Copy link
Collaborator

  1. the generated ZIP folder does not contain the correct data about Product Information or Installed tools
    I am attaching mine ZIP here, please take a look:
    bug_report_20250909_124336.zip

and log file just in case:
log.txt

@alirana01
Copy link
Collaborator Author

  1. the generated ZIP folder does not contain the correct data about Product Information or Installed tools
    I am attaching mine ZIP here, please take a look:
    bug_report_20250909_124336.zip

and log file just in case: log.txt

Hi @AndriiFilippov
kindly verify again its changed now instead of running existing handlers I am now avoiding that and running the commands in the respective class manually to avoid waiting for jobs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

♻️ Duplicate comments (4)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (4)

64-64: Use uppercase for static final field naming convention.

Java naming conventions recommend using uppercase letters with underscores for static final fields.

Apply this fix:

-private static final String UNKNOWN = "Unknown"; //$NON-NLS-1$
+private static final String UNKNOWN_VALUE = "Unknown"; //$NON-NLS-1$

Also update usages at lines 196-198:

-String osName = System.getProperty("os.name", UNKNOWN); //$NON-NLS-1$
-String osVersion = System.getProperty("os.version", UNKNOWN); //$NON-NLS-1$
-String arch = System.getProperty("os.arch", UNKNOWN); //$NON-NLS-1$
+String osName = System.getProperty("os.name", UNKNOWN_VALUE); //$NON-NLS-1$
+String osVersion = System.getProperty("os.version", UNKNOWN_VALUE); //$NON-NLS-1$
+String arch = System.getProperty("os.arch", UNKNOWN_VALUE); //$NON-NLS-1$

103-109: Fix incorrect Windows EIM logs path.

The code uses APPDATA (roaming) but then appends \Local\eim\logs. You should use LOCALAPPDATA environment variable instead for the local app data directory.

Apply this fix:

 case Platform.OS_WIN32:
-    eimPath = System.getenv("APPDATA"); //$NON-NLS-1$
+    eimPath = System.getenv("LOCALAPPDATA"); //$NON-NLS-1$
     if (!StringUtil.isEmpty(eimPath))
     {
-        eimPath = eimPath + "\\Local\\eim\\logs"; //$NON-NLS-1$
+        eimPath = eimPath + "\\eim\\logs"; //$NON-NLS-1$
     }
     break;

206-207: Compilation error: Incorrect method names for memory retrieval.

The methods getFreeMemorySize() and getTotalMemorySize() don't exist on com.sun.management.OperatingSystemMXBean. Use the correct method names.

Apply this fix:

-    freePhys = osBean.getFreeMemorySize();
-    totalPhys = osBean.getTotalMemorySize();
+    freePhys = osBean.getFreePhysicalMemorySize();
+    totalPhys = osBean.getTotalPhysicalMemorySize();

128-129: Prevent catastrophic copy when EIM path is empty.

When the EIM path isn't found, the method returns new File("") which resolves to the current working directory. This could cause FileUtil.copyDirectory to copy the entire working directory into the bug report.

Apply this fix to return null when path is empty and guard the copy operation:

-    return new File(eimPath);
+    if (StringUtil.isEmpty(eimPath)) {
+        return null;
+    }
+    return new File(eimPath);

And update the copy operation at lines 290-292:

 File eimLogPath = getEimLogPath();
-File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$ )
-FileUtil.copyDirectory(eimLogPath, eimLogDir);
+if (eimLogPath != null && eimLogPath.exists() && eimLogPath.isDirectory()) {
+    File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$
+    FileUtil.copyDirectory(eimLogPath, eimLogDir);
+}

Also applies to: 290-292

🧹 Nitpick comments (1)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (1)

262-301: Add error handling for individual file creation failures.

The current implementation doesn't handle partial failures gracefully. If any file creation fails early, the method will throw an exception and skip creating the zip file entirely.

Consider catching exceptions for individual operations and continuing with what's available:

 public String generateBugReport()
 {
     if (!bugReportDirectory.exists())
     {
         bugReportDirectory.mkdirs();
     }
 
+    List<String> errors = new ArrayList<>();
     try
     {
-        File installedToolsFile = getInstalledToolsInfoFile();
-        File productInfoFile = getProductInfoFile();
-        File basicSysInfoFile = createBasicSystemInfoFile();
+        File installedToolsFile = null;
+        File productInfoFile = null;
+        File basicSysInfoFile = null;
+        
+        try {
+            installedToolsFile = getInstalledToolsInfoFile();
+        } catch (IOException e) {
+            errors.add("Failed to get installed tools info: " + e.getMessage());
+            Logger.log(e);
+        }
+        
+        try {
+            productInfoFile = getProductInfoFile();
+        } catch (IOException e) {
+            errors.add("Failed to get product info: " + e.getMessage());
+            Logger.log(e);
+        }
+        
+        try {
+            basicSysInfoFile = createBasicSystemInfoFile();
+        } catch (IOException e) {
+            errors.add("Failed to create basic system info: " + e.getMessage());
+            Logger.log(e);
+        }
 
         List<File> filesToZip = new LinkedList<>();
-        filesToZip.add(installedToolsFile);
-        filesToZip.add(productInfoFile);
-        filesToZip.add(basicSysInfoFile);
+        if (installedToolsFile != null) filesToZip.add(installedToolsFile);
+        if (productInfoFile != null) filesToZip.add(productInfoFile);
+        if (basicSysInfoFile != null) filesToZip.add(basicSysInfoFile);
+        
+        // If there were errors, create an error log file
+        if (!errors.isEmpty()) {
+            File errorLog = FileUtil.createFileWithContentsInDirectory("errors.txt",
+                String.join(System.lineSeparator(), errors),
+                bugReportDirectory.getAbsolutePath());
+            filesToZip.add(errorLog);
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0658b and c55b406.

📒 Files selected for processing (2)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (1 hunks)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/GenerateBugReportCommandHandler.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/GenerateBugReportCommandHandler.java (4)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (1)
  • BugReportGenerator (52-455)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/GithubIssueOpener.java (1)
  • GithubIssueOpener (18-34)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/logging/Logger.java (1)
  • Logger (21-137)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/update/Messages.java (1)
  • Messages (9-88)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (8)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePlugin.java (1)
  • IDFCorePlugin (20-77)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java (1)
  • IDFCorePreferenceConstants (24-79)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/ProcessBuilderFactory.java (1)
  • ProcessBuilderFactory (16-163)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/SystemExecutableFinder.java (1)
  • SystemExecutableFinder (19-131)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/logging/Logger.java (1)
  • Logger (21-137)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/FileUtil.java (1)
  • FileUtil (48-493)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java (1)
  • IDFUtil (59-962)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/StringUtil.java (1)
  • StringUtil (11-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: build_macos
🔇 Additional comments (1)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/handlers/GenerateBugReportCommandHandler.java (1)

1-86: LGTM! The handler implementation is clean and straightforward.

The command handler correctly integrates with the bug report generation infrastructure and provides appropriate user feedback through the console.

Comment on lines +310 to +315
Logger.log("GIT path:" + gitPath); //$NON-NLS-1$
String gitExecutablePath = gitPath.getDevice();
if (StringUtil.isEmpty(gitExecutablePath))
{
gitExecutablePath = new IDFEnvironmentVariables().getEnvValue(IDFEnvironmentVariables.GIT_PATH);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Logic error: git path extraction is incorrect.

IPath.getDevice() returns the device identifier (e.g., drive letter on Windows), not the full path. You should use toOSString() to get the complete path.

Apply this fix:

 IPath gitPath = new SystemExecutableFinder().find("git"); //$NON-NLS-1$
 Logger.log("GIT path:" + gitPath); //$NON-NLS-1$
-String gitExecutablePath = gitPath.getDevice();
+String gitExecutablePath = gitPath != null ? gitPath.toOSString() : null;
 if (StringUtil.isEmpty(gitExecutablePath))
 {
     gitExecutablePath = new IDFEnvironmentVariables().getEnvValue(IDFEnvironmentVariables.GIT_PATH);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Logger.log("GIT path:" + gitPath); //$NON-NLS-1$
String gitExecutablePath = gitPath.getDevice();
if (StringUtil.isEmpty(gitExecutablePath))
{
gitExecutablePath = new IDFEnvironmentVariables().getEnvValue(IDFEnvironmentVariables.GIT_PATH);
}
IPath gitPath = new SystemExecutableFinder().find("git"); //$NON-NLS-1$
Logger.log("GIT path:" + gitPath); //$NON-NLS-1$
String gitExecutablePath = gitPath != null ? gitPath.toOSString() : null;
if (StringUtil.isEmpty(gitExecutablePath))
{
gitExecutablePath = new IDFEnvironmentVariables().getEnvValue(IDFEnvironmentVariables.GIT_PATH);
}
🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around lines 310 to 315, the code incorrectly uses IPath.getDevice() (which
returns only the device/drive) to obtain the git path; change it to use
gitPath.toOSString() to get the full OS path string, update the
gitExecutablePath assignment to use that value, and adjust the logging to print
the full path; keep the existing fallback to IDFEnvironmentVariables.GIT_PATH if
the resulting string is empty or null.

Comment on lines +349 to +367
{
IPath gitPath = new org.eclipse.core.runtime.Path(gitExecutablePath);
if (gitPath.toFile().exists())
{
String gitDir = gitPath.removeLastSegments(1).toOSString();
String path1 = environment.get("PATH"); //$NON-NLS-1$
String path2 = environment.get("Path"); //$NON-NLS-1$
if (!StringUtil.isEmpty(path1) && !path1.contains(gitDir)) // Git not found on the PATH environment
{
path1 = gitDir.concat(";").concat(path1); //$NON-NLS-1$
environment.put("PATH", path1); //$NON-NLS-1$
}
else if (!StringUtil.isEmpty(path2) && !path2.contains(gitDir)) // Git not found on the Path environment
{
path2 = gitDir.concat(";").concat(path2); //$NON-NLS-1$
environment.put("Path", path2); //$NON-NLS-1$
}
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider File.pathSeparator for cross-platform PATH handling.

The code uses ; as the path separator, which is Windows-specific. On Unix-like systems, : is the path separator.

Apply this fix for cross-platform compatibility:

 if (!StringUtil.isEmpty(path1) && !path1.contains(gitDir)) // Git not found on the PATH environment
 {
-    path1 = gitDir.concat(";").concat(path1); //$NON-NLS-1$
+    path1 = gitDir.concat(File.pathSeparator).concat(path1);
     environment.put("PATH", path1); //$NON-NLS-1$
 }
 else if (!StringUtil.isEmpty(path2) && !path2.contains(gitDir)) // Git not found on the Path environment
 {
-    path2 = gitDir.concat(";").concat(path2); //$NON-NLS-1$
+    path2 = gitDir.concat(File.pathSeparator).concat(path2);
     environment.put("Path", path2); //$NON-NLS-1$
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
IPath gitPath = new org.eclipse.core.runtime.Path(gitExecutablePath);
if (gitPath.toFile().exists())
{
String gitDir = gitPath.removeLastSegments(1).toOSString();
String path1 = environment.get("PATH"); //$NON-NLS-1$
String path2 = environment.get("Path"); //$NON-NLS-1$
if (!StringUtil.isEmpty(path1) && !path1.contains(gitDir)) // Git not found on the PATH environment
{
path1 = gitDir.concat(";").concat(path1); //$NON-NLS-1$
environment.put("PATH", path1); //$NON-NLS-1$
}
else if (!StringUtil.isEmpty(path2) && !path2.contains(gitDir)) // Git not found on the Path environment
{
path2 = gitDir.concat(";").concat(path2); //$NON-NLS-1$
environment.put("Path", path2); //$NON-NLS-1$
}
}
}
{
IPath gitPath = new org.eclipse.core.runtime.Path(gitExecutablePath);
if (gitPath.toFile().exists())
{
String gitDir = gitPath.removeLastSegments(1).toOSString();
String path1 = environment.get("PATH"); //$NON-NLS-1$
String path2 = environment.get("Path"); //$NON-NLS-1$
if (!StringUtil.isEmpty(path1) && !path1.contains(gitDir)) // Git not found on the PATH environment
{
path1 = gitDir.concat(File.pathSeparator).concat(path1);
environment.put("PATH", path1); //$NON-NLS-1$
}
else if (!StringUtil.isEmpty(path2) && !path2.contains(gitDir)) // Git not found on the Path environment
{
path2 = gitDir.concat(File.pathSeparator).concat(path2);
environment.put("Path", path2); //$NON-NLS-1$
}
}
}
🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around lines 349 to 367, the code appends a hard-coded ";" when prepending
gitDir to PATH/Path which is Windows-only; replace the literal ";" with the
platform-specific separator by using java.io.File.pathSeparator when
concatenating the new PATH value, and ensure any string concat calls use that
File.pathSeparator so the PATH is corrected on Unix-like systems as well.

Comment on lines +408 to +423
private void showEspIdfVersion()
{
if (IDFUtil.getIDFPath() != null && IDFUtil.getIDFPythonEnvPath() != null)
{
List<String> commands = new ArrayList<>();
commands.add(IDFUtil.getIDFPythonEnvPath());
commands.add(IDFUtil.getIDFPythonScriptFile().getAbsolutePath());
commands.add("--version"); //$NON-NLS-1$
Map<String, String> envMap = new IDFEnvironmentVariables().getSystemEnvMap();
Logger.log(runCommand(commands, envMap));
}
else
{
Logger.log("ESP-IDF version cannot be checked. IDF_PATH or IDF_PYTHON_ENV_PATH are not set."); //$NON-NLS-1$
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

ESP-IDF version output is not captured in the report.

The showEspIdfVersion() method only logs the ESP-IDF version to the logger but doesn't append it to the product information file.

Modify the method to return the version string and append it to the StringBuilder:

-private void showEspIdfVersion()
+private String getEspIdfVersion()
 {
     if (IDFUtil.getIDFPath() != null && IDFUtil.getIDFPythonEnvPath() != null)
     {
         List<String> commands = new ArrayList<>();
         commands.add(IDFUtil.getIDFPythonEnvPath());
         commands.add(IDFUtil.getIDFPythonScriptFile().getAbsolutePath());
         commands.add("--version"); //$NON-NLS-1$
         Map<String, String> envMap = new IDFEnvironmentVariables().getSystemEnvMap();
-        Logger.log(runCommand(commands, envMap));
+        String version = runCommand(commands, envMap);
+        Logger.log(version);
+        return version;
     }
     else
     {
         Logger.log("ESP-IDF version cannot be checked. IDF_PATH or IDF_PYTHON_ENV_PATH  are not set."); //$NON-NLS-1$
+        return NOT_FOUND_MSG;
     }
 }

And update line 399:

-showEspIdfVersion();
+sb.append("ESP-IDF Version: ").append(getEspIdfVersion());
+sb.append(System.lineSeparator());

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around lines 408-423, showEspIdfVersion() currently only logs the version;
change it to return the version string instead: build the commands and env map
as before, call runCommand(...) and store its result in a String (or a
descriptive message if null/error), log it as now and then return that string;
adjust the method signature from void to String. Then at the call site around
line 399, capture the returned String and append it to the product information
StringBuilder (with a label/newline as appropriate) instead of relying solely on
Logger.log.

Comment on lines +431 to +439
IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, env);
if (status == null)
{
Logger.log(IDFCorePlugin.getPlugin(), IDFCorePlugin.errorStatus("Status can't be null", null)); //$NON-NLS-1$
}

// process export command output
exportCmdOp = status.getMessage();
Logger.log(exportCmdOp);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle null status more gracefully.

The null check for status logs an error but then continues to call status.getMessage() on line 438, which will throw a NullPointerException.

Apply this fix:

 IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, env);
 if (status == null)
 {
     Logger.log(IDFCorePlugin.getPlugin(), IDFCorePlugin.errorStatus("Status can't be null", null)); //$NON-NLS-1$
+    return exportCmdOp;
 }
 
 // process export command output
 exportCmdOp = status.getMessage();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, env);
if (status == null)
{
Logger.log(IDFCorePlugin.getPlugin(), IDFCorePlugin.errorStatus("Status can't be null", null)); //$NON-NLS-1$
}
// process export command output
exportCmdOp = status.getMessage();
Logger.log(exportCmdOp);
IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, env);
if (status == null)
{
Logger.log(IDFCorePlugin.getPlugin(), IDFCorePlugin.errorStatus("Status can't be null", null)); //$NON-NLS-1$
return exportCmdOp;
}
// process export command output
exportCmdOp = status.getMessage();
Logger.log(exportCmdOp);
🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around lines 431 to 439, the code logs an error when
processRunner.runInBackground returns null but then immediately calls
status.getMessage(), causing an NPE; update the control flow so that after
logging the error you either return/throw or assign a safe default and skip
calling status.getMessage() (for example set exportCmdOp to an empty string or
null and bypass further processing), ensuring no methods are invoked on a null
status and preserving existing logging of the failure.

@AndriiFilippov
Copy link
Collaborator

AndriiFilippov commented Sep 10, 2025

@alirana01 hi!

Tested under: OS - Windows 11 ESP-IDF: v5.5

Install tools -> execute "Generate Bug Report" :

  1. after bug report has been generated the console output looks fine:
================================
Bug report completed. You can find the report at: C:\Users\andri\workspaceBugReport\bug_report_20250909_124336.zip 
=================================


Opening browser to create a new issue...

but error occurs in Error log Command 'com.espressif.idf.ui.command.generateBugReport' failed

error.log

@alirana01 hi!

Tested under: OS - Windows 11 ESP-IDF: v5.5

Install tools -> execute "Generate Bug Report" :

  1. after bug report has been generated the console output looks fine:
================================
Bug report completed. You can find the report at: C:\Users\andri\workspaceBugReport\bug_report_20250909_124336.zip 
=================================


Opening browser to create a new issue...

but error occurs in Error log Command 'com.espressif.idf.ui.command.generateBugReport' failed

error.log

@alirana01 do you think we could convert the path into a clickable link? just for comfortable navigation

@AndriiFilippov
Copy link
Collaborator

@alirana01
also, noticed on Mac it does include eim_log files during ZIP generation, but on Windows or Linux not (I have eim_idf.json files installed there) .
As I could see from description - the PR should works with v4.0.0 as well
Could you please confirm that .

Windows logs:
log 9.txt

@alirana01
Copy link
Collaborator Author

@alirana01 also, noticed on Mac it does include eim_log files during ZIP generation, but on Windows or Linux not (I have eim_idf.json files installed there) . As I could see from description - the PR should works with v4.0.0 as well Could you please confirm that .

Windows logs: log 9.txt

I can see some ambiguities in the logs probably from the same workspace as the other PR for the system environment and tools could be behaving differently please rerun and share logs from a clean and properly installed idf tools workspace

@AndriiFilippov
Copy link
Collaborator

@alirana01 please, take a look
clean workspace, clean env.
I do have ESP-IDF version v5.3 installed using EIM installer, but in this case I was using separately downloaded IDF.
bug_report_20250915_202540.zip

here I was using ESP-IDF from EIM installed.
bug_report_20250915_203036.zip

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (4)

400-406: Include ESP‑IDF version in product_information.txt (not just logs).

Return the version string and append it to sb.

-        showEspIdfVersion();
+        sb.append("ESP-IDF Version: ").append(getEspIdfVersion()).append(System.lineSeparator());
-    private void showEspIdfVersion()
+    private String getEspIdfVersion()
     {
         if (IDFUtil.getIDFPath() != null && IDFUtil.getIDFPythonEnvPath() != null)
         {
             List<String> commands = new ArrayList<>();
             commands.add(IDFUtil.getIDFPythonEnvPath());
             commands.add(IDFUtil.getIDFPythonScriptFile().getAbsolutePath());
             commands.add("--version"); //$NON-NLS-1$
             Map<String, String> envMap = new IDFEnvironmentVariables().getSystemEnvMap();
-            Logger.log(runCommand(commands, envMap));
+            String version = runCommand(commands, envMap);
+            Logger.log(version);
+            return version;
         }
         else
         {
             Logger.log("ESP-IDF version cannot be checked. IDF_PATH or IDF_PYTHON_ENV_PATH  are not set."); //$NON-NLS-1$
+            return NOT_FOUND_MSG;
         }
     }

Also applies to: 409-424


295-303: Optional: delete the temporary folder after zipping to avoid confusion.

Users reported seeing both zipped and unzipped folders. Consider cleanup post-zip (or a preference).

         // Zip the bug report directory
         FileUtil.zipDirectory(bugReportDirectory, bugReportDirectory.getAbsolutePath() + ".zip"); //$NON-NLS-1$
+        // Optional: clean up the staging directory after zip
+        FileUtil.deleteDirectory(bugReportDirectory);

273-277: Remove unused filesToZip list.

The list is built but never used.

-            List<File> filesToZip = new LinkedList<>();
-            filesToZip.add(installedToolsFile);
-            filesToZip.add(productInfoFile);
-            filesToZip.add(basicSysInfoFile);

239-241: Optional: add .txt extension for basic system info file.

Improves readability on all platforms.

-        return FileUtil.createFileWithContentsInDirectory("basic_system_info", sb.toString(), //$NON-NLS-1$
+        return FileUtil.createFileWithContentsInDirectory("basic_system_info.txt", sb.toString(), //$NON-NLS-1$
                 bugReportDirectory.getAbsolutePath());
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c55b406 and 381a532.

📒 Files selected for processing (1)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (8)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePlugin.java (1)
  • IDFCorePlugin (20-77)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/IDFCorePreferenceConstants.java (1)
  • IDFCorePreferenceConstants (24-79)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/ProcessBuilderFactory.java (1)
  • ProcessBuilderFactory (16-163)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/SystemExecutableFinder.java (1)
  • SystemExecutableFinder (19-131)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/logging/Logger.java (1)
  • Logger (21-137)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/FileUtil.java (1)
  • FileUtil (48-493)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/IDFUtil.java (1)
  • IDFUtil (59-962)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/StringUtil.java (1)
  • StringUtil (11-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_windows
🔇 Additional comments (8)
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java (8)

138-192: Good: selective IDE metadata logs only.

Filtering to .log (active and recent backups) and version.ini matches the privacy/perf ask.

Please confirm this addresses the request to exclude plugin data and large metadata content.


118-123: Verify EIM log locations on macOS/Linux.

Paths may differ across versions/distros; ensure logs are actually present in:

  • macOS: ~/Library/Application Support/eim/logs
  • Linux: ~/.local/share/eim/logs

Would you like me to add a fallback search (e.g., try both eim/.eim and common distro paths) if the primary path doesn’t exist?

Also applies to: 110-116


98-129: EIM logs path resolution: fix Windows var, Linux subdir, and avoid catastrophic copy on empty path.

  • Windows must use LOCALAPPDATA, not APPDATA (Roaming). Also don’t append “\Local” twice.
  • Linux path likely “~/.local/share/eim/logs” (not “.eim”).
  • Return null when unresolved; returning new File("") risks copying the CWD.
-    private File getEimLogPath()
+    private File getEimLogPath()
     {
-        String eimPath = StringUtil.EMPTY;
+        String eimPath = StringUtil.EMPTY;
         switch (Platform.getOS())
         {
         case Platform.OS_WIN32:
-            eimPath = System.getenv("APPDATA"); //$NON-NLS-1$
-            if (!StringUtil.isEmpty(eimPath))
-            {
-                eimPath = eimPath + "\\Local\\eim\\logs"; //$NON-NLS-1$
-            }
+            eimPath = System.getenv("LOCALAPPDATA"); //$NON-NLS-1$
+            if (!StringUtil.isEmpty(eimPath)) {
+                eimPath = eimPath + "\\eim\\logs"; //$NON-NLS-1$
+            }
             break;
         case Platform.OS_MACOSX:
             eimPath = System.getProperty("user.home"); //$NON-NLS-1$
             if (!StringUtil.isEmpty(eimPath))
             {
                 eimPath = eimPath + "/Library/Application Support/eim/logs"; //$NON-NLS-1$
             }
             break;
         case Platform.OS_LINUX:
             eimPath = System.getProperty("user.home"); //$NON-NLS-1$
             if (!StringUtil.isEmpty(eimPath))
             {
-                eimPath = eimPath + "/.local/share/.eim/logs"; //$NON-NLS-1$
+                eimPath = eimPath + "/.local/share/eim/logs"; //$NON-NLS-1$
             }
             break;
         default:
             break;
         }
-
-        return new File(eimPath);
+        if (StringUtil.isEmpty(eimPath)) {
+            return null;
+        }
+        return new File(eimPath);
     }

Please verify actual Linux/macOS EIM log locations across targets and adjust strings if needed.


206-208: Use correct OperatingSystemMXBean methods (compile-time fix).

getFreeMemorySize()/getTotalMemorySize() don’t exist. Use physical variants.

-            freePhys = osBean.getFreeMemorySize();
-            totalPhys = osBean.getTotalMemorySize();
+            freePhys = osBean.getFreePhysicalMemorySize();
+            totalPhys = osBean.getTotalPhysicalMemorySize();

311-316: Fix Git path extraction and null-safety.

IPath.getDevice() returns only the drive, not path, and NPE if gitPath is null.

-        IPath gitPath = new SystemExecutableFinder().find("git"); //$NON-NLS-1$
-        Logger.log("GIT path:" + gitPath); //$NON-NLS-1$
-        String gitExecutablePath = gitPath.getDevice();
+        IPath gitPath = new SystemExecutableFinder().find("git"); //$NON-NLS-1$
+        Logger.log("GIT path:" + gitPath); //$NON-NLS-1$
+        String gitExecutablePath = gitPath != null ? gitPath.toOSString() : null;
         if (StringUtil.isEmpty(gitExecutablePath))
         {
             gitExecutablePath = new IDFEnvironmentVariables().getEnvValue(IDFEnvironmentVariables.GIT_PATH);
         }

432-441: Avoid NPE when process status is null.

You log the null but still dereference status.

-            IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, env);
-            if (status == null)
-            {
-                Logger.log(IDFCorePlugin.getPlugin(), IDFCorePlugin.errorStatus("Status can't be null", null)); //$NON-NLS-1$
-            }
-
-            // process export command output
-            exportCmdOp = status.getMessage();
-            Logger.log(exportCmdOp);
+            IStatus status = processRunner.runInBackground(arguments, org.eclipse.core.runtime.Path.ROOT, env);
+            if (status == null) {
+                Logger.log(IDFCorePlugin.getPlugin(), IDFCorePlugin.errorStatus("Status can't be null", null)); //$NON-NLS-1$
+                return exportCmdOp;
+            }
+            exportCmdOp = status.getMessage();
+            Logger.log(exportCmdOp);

349-368: Use File.pathSeparator for PATH to be cross‑platform.

Hardcoding “;” breaks on Unix-like systems (uses “:”).

-            if (!StringUtil.isEmpty(path1) && !path1.contains(gitDir)) // Git not found on the PATH environment
-            {
-                path1 = gitDir.concat(";").concat(path1); //$NON-NLS-1$
+            if (!StringUtil.isEmpty(path1) && !path1.contains(gitDir)) // Git not found on the PATH environment
+            {
+                path1 = gitDir.concat(File.pathSeparator).concat(path1);
                 environment.put("PATH", path1); //$NON-NLS-1$
             }
             else if (!StringUtil.isEmpty(path2) && !path2.contains(gitDir)) // Git not found on the Path environment
             {
-                path2 = gitDir.concat(";").concat(path2); //$NON-NLS-1$
+                path2 = gitDir.concat(File.pathSeparator).concat(path2);
                 environment.put("Path", path2); //$NON-NLS-1$
             }

290-294: Guard optional EIM logs copy and skip when unavailable.

Avoid NPE and accidental massive copies when path is null/nonexistent.

-        File eimLogPath = getEimLogPath();
-        Logger.log("EIM log path: " + eimLogPath.getAbsolutePath()); //$NON-NLS-1$
-        File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$
-        FileUtil.copyDirectory(eimLogPath, eimLogDir);
+        File eimLogPath = getEimLogPath();
+        if (eimLogPath != null && eimLogPath.exists() && eimLogPath.isDirectory()) {
+            Logger.log("EIM log path: " + eimLogPath.getAbsolutePath()); //$NON-NLS-1$
+            File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$
+            FileUtil.copyDirectory(eimLogPath, eimLogDir);
+        } else {
+            Logger.log("EIM log path not found. Skipping EIM logs copy."); //$NON-NLS-1$
+        }

filesToZip.add(basicSysInfoFile);

List<File> metadataLogsFile = getIdeMetadataLogsFile();
File ideLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "ide_metadata_logs"); //$NON-NLS-1$ )
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix stray ) causing compilation errors.

There’s an extra closing parenthesis after the $NON-NLS-1$ comment.

- File ideLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "ide_metadata_logs"); //$NON-NLS-1$ )
+ File ideLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "ide_metadata_logs"); //$NON-NLS-1$
- File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$ )
+ File eimLogDir = new File(bugReportDirectory.getAbsolutePath() + File.separator + "eim_logs"); //$NON-NLS-1$

Also applies to: 292-292

🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around lines 279 and 292, there are stray closing parentheses immediately after
the //$NON-NLS-1$ comments causing compilation errors; remove the extra ')' at
both locations so the File constructor calls end with ); (i.e., ensure the
comment is outside the parentheses and the method call is properly closed).

arguments.add(IDFConstants.TOOLS_LIST_CMD);
Logger.log("Executing command: " + String.join(" ", arguments)); //$NON-NLS-1$ //$NON-NLS-2$
Map<String, String> environment = new HashMap<>(IDFUtil.getSystemEnv());
Logger.log(environment.toString());
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove logging of full environment map (PII/security risk).

Dumping env vars can leak tokens/credentials.

-        Logger.log(environment.toString());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Logger.log(environment.toString());
🤖 Prompt for AI Agents
In
bundles/com.espressif.idf.core/src/com/espressif/idf/core/bug/BugReportGenerator.java
around line 323, remove the call that logs the full environment map
(Logger.log(environment.toString())) because it can expose PII/credentials;
either delete the log entirely or replace it with a safe alternative such as
logging only non-sensitive keys or a redacted summary (e.g., count of variables
or a whitelist of allowed keys), ensuring no environment values are printed.

@alirana01 alirana01 merged commit a6383d9 into master Sep 24, 2025
4 of 6 checks passed
@alirana01 alirana01 deleted the IEP-1618 branch September 24, 2025 10:54
AndriiFilippov added a commit that referenced this pull request Sep 24, 2025
@alirana01 alirana01 restored the IEP-1618 branch September 25, 2025 08:29
@kolipakakondal kolipakakondal added this to the v3.7.0 milestone Oct 9, 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.

5 participants