Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEP-1333: ESP-IDF Manager: Cannot invoke "String.indexOf(int)" because "value" is null #1058

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

alirana01
Copy link
Collaborator

@alirana01 alirana01 commented Oct 3, 2024

Description

Please see ticket

Fixes # (IEP-1333)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

Try to reproduce using steps in ticket

Test Configuration:

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

Checklist

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

Summary by CodeRabbit

  • New Features

    • Enhanced IDF version handling by retrieving version information from environment variables if it cannot be extracted from command output.
  • Bug Fixes

    • Improved robustness of version handling logic to ensure accurate IDF version information is maintained.
  • Tests

    • Removed two test methods from the SBOM tool test suite, reflecting a change in testing strategy.
    • Commented out two test methods related to project creation and DFU capabilities.
  • Chores

    • Updated the CI workflow configuration to use a different runner environment for building the project on Windows.

@alirana01 alirana01 self-assigned this Oct 3, 2024
Copy link

coderabbitai bot commented Oct 3, 2024

Walkthrough

The changes in this pull request modify the processExportCmdOutput method of the ToolsJob class to enhance IDF version handling. A new conditional block is introduced to manage cases where the IDF version cannot be extracted from command output. In such scenarios, the method attempts to retrieve the version from environment variables, specifically looking for ESP_IDF_VERSION. This adjustment improves the robustness of version management within the application.

Changes

File Path Change Summary
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java Updated processExportCmdOutput to add logic for retrieving IDF version from environment variables if not found in command output.
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectSBOMTest.java Removed two test methods related to SBOM generation, indicating a shift in testing strategy.
tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectTest.java Commented out two test methods related to DFU project creation and context menu cleaning, indicating a change in focus.
.github/workflows/ci_windows.yml Updated job runner from eclipse to eclipseUpd for Windows build workflow.

Possibly related PRs

Suggested reviewers

  • AndriiFilippov
  • kolipakakondal

🐇 "In the land of code where the rabbits play,
A version check brightens the day.
If command output fails to show,
From the environment, the truth will flow.
With hops of logic, we ensure it’s right,
A robust version, shining bright!" 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c45c2c0 and 039c7bb.

📒 Files selected for processing (1)
  • .github/workflows/ci_windows.yml (1 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/ci_windows.yml

16-16: label "eclipseUpd" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "macos-11", "macos-11.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

🔇 Additional comments (1)
.github/workflows/ci_windows.yml (1)

16-16: ⚠️ Potential issue

Verify the custom runner label and consider improving its documentation

The change from eclipse to eclipseUpd in the runs-on specification suggests an update to the runner environment. However, eclipseUpd is not a standard GitHub-hosted runner label, which could lead to potential issues:

  1. If eclipseUpd is a custom self-hosted runner, it should be clearly documented to avoid confusion.
  2. There's a risk of the workflow failing if the eclipseUpd runner doesn't exist or is misconfigured.

To address these concerns:

  1. Verify that the eclipseUpd runner exists and is correctly set up in your GitHub Actions environment.
  2. Consider adding a comment in the workflow file explaining the purpose and setup of this custom runner.
  3. If possible, use more descriptive names for custom runners to improve clarity (e.g., windows-eclipse-updated instead of eclipseUpd).

To confirm the existence and configuration of the custom runner, you can run the following GitHub CLI command:

Replace :owner and :repo with your GitHub username/organization and repository name, respectively.

If you confirm that these are custom self-hosted runners, consider updating the workflow file to use the self-hosted label explicitly:

runs-on:
  - self-hosted
  - eclipseUpd
  - BrnoWIN0007

This change clarifies that these are custom runners and may help prevent confusion for other developers working on this project.

🧰 Tools
🪛 actionlint

16-16: label "eclipseUpd" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "macos-11", "macos-11.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 459e2b9 and d082037.

📒 Files selected for processing (1)
  • bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (1 hunks)
🔇 Additional comments (1)
bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/tools/ToolsJob.java (1)

Line range hint 1-624: Overall assessment of changes to ToolsJob.java

The changes to the processExportCmdOutput method improve the handling of IDF version extraction by adding a fallback mechanism. This enhancement addresses a potential issue where the version might not be found in the command output.

While this is a positive change, there are opportunities for further improvement in error handling, logging, and code style as detailed in the previous comment. These suggestions would make the code more robust and maintainable.

The rest of the file remains unchanged, and the overall structure and functionality of the ToolsJob class are preserved.

Comment on lines +127 to +130
else
{
idfToolSet.setIdfVersion(idfToolSet.getEnvVars().computeIfAbsent(IDFEnvironmentVariables.ESP_IDF_VERSION, k -> StringUtil.EMPTY));
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Improve error handling and code style for IDF version extraction

The addition of a fallback mechanism for retrieving the IDF version is a good improvement. However, there are a few areas that could be enhanced:

  1. The indentation of the else block is incorrect. It should be aligned with the if statement above.
  2. Consider adding a log message when falling back to the environment variable, to help with debugging.
  3. Instead of using StringUtil.EMPTY as the default value, it might be better to use a more descriptive default or throw an exception if the version can't be determined.

Here's a suggested improvement:

 if (matcher.find())
 {
     idfToolSet.setIdfVersion(matcher.group(1));
 }
-		else 
-		{
-			idfToolSet.setIdfVersion(idfToolSet.getEnvVars().computeIfAbsent(IDFEnvironmentVariables.ESP_IDF_VERSION, k -> StringUtil.EMPTY));
-		}
+else
+{
+    String envVersion = idfToolSet.getEnvVars().get(IDFEnvironmentVariables.ESP_IDF_VERSION);
+    if (envVersion != null && !envVersion.isEmpty()) {
+        Logger.log("IDF version not found in command output. Using version from environment: " + envVersion);
+        idfToolSet.setIdfVersion(envVersion);
+    } else {
+        Logger.log("Unable to determine IDF version from command output or environment variables.");
+        throw new IllegalStateException("Unable to determine IDF version");
+    }
+}

This change improves error handling, adds logging, and throws an exception if the version can't be determined, which is better than silently using an empty string.

Committable suggestion was skipped due to low confidence.

else
{
idfToolSet.setIdfVersion(idfToolSet.getEnvVars().computeIfAbsent(IDFEnvironmentVariables.ESP_IDF_VERSION, k -> StringUtil.EMPTY));
}
Copy link
Collaborator

@kolipakakondal kolipakakondal Oct 3, 2024

Choose a reason for hiding this comment

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

Not sure if this is the right way to approach the problem, I think the issue was because regular expression is not capturing the esp-idf version when it was on master branch

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually the output from the python is like this

Users/aliazamrana/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
ESP-IDF v5.4-dev-3201-g46acfdce96

which makes it difficult to have a single regex to parse all the possibilities so it would be better I think to fallback to the env variable that is being exported by the export script

Copy link
Collaborator

Choose a reason for hiding this comment

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

idf.py --version output on master

/Users/kondalkolipaka/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(
ESP-IDF v5.4-dev-3201-g46acfdce96

on 5.2.2

ESP-IDF v5.2.2-dirty

@kolipakakondal
Copy link
Collaborator

@AndriiFilippov please verify

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

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

@AndriiFilippov
Copy link
Collaborator

@alirana01 hi !

Tested under:
OS : Mac arm64 / Windows 11
ESP-IDF: master

Windows 11 ✅
Mac arm64:
able to download and install tools, build flash and monitor. everything to be fine, but during flash I see this message in console:

/Users/andriifilippov/.espressif/python_env/idf5.4_py3.9_env/lib/python3.9/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(

Could you please check if you see this message as well or this is my local issue.

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.

4 participants