Skip to content

IEP-1772 Show meaningful error message instead of invalid command name "program_esp_bins" - #1481

Open
sigmaaa wants to merge 2 commits into
masterfrom
IEP-1772
Open

IEP-1772 Show meaningful error message instead of invalid command name "program_esp_bins"#1481
sigmaaa wants to merge 2 commits into
masterfrom
IEP-1772

Conversation

@sigmaaa

@sigmaaa sigmaaa commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Description

Replaced invalid command name "program_esp_bins" with userfriendly clickable message that allows edit the target and select the board:

image

Note: After further thought, I went with failing early via a pop-up instead. It avoids waiting for and parsing every OpenOCD message, and it's more accurate: invalid command name "program_esp_bins" can stem from a corrupted configuration file too, not just an unselected board.

image

Also added the same check for jtag flashing

Fixes # (IEP-1772)

Type of change

Please delete options that are not relevant.

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

How has this been tested?

Connect the esp chip, select a port, but do not select a board and start debug session

Test Configuration:

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

Dependent components impacted by this PR:

  • Component 1
  • Component 2

Checklist

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

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Debug operations now detect when no board is selected before starting, and show a “board not selected” confirmation dialog that lets users jump to edit their launch target.
    • JTAG flash operations now block flashing when board configuration is missing and prompt users with the same confirmation dialog to configure the target.
  • Refactor
    • Improved board configuration checks to determine when board selection is resolvable before proceeding.

@sigmaaa sigmaaa self-assigned this Jun 18, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds “no board selected” validation to the OpenOCD debug and serial JTAG flash launch paths. Board configuration resolution is centralized in JtagVariableResolver; unresolved configurations now trigger dialogs that can open the launch target editor instead of proceeding.

Changes

Board-not-selected guard across debug and flash launch paths

Layer / File(s) Summary
JtagVariableResolver board-config resolution refactor
bundles/com.espressif.idf.core/.../variable/JtagVariableResolver.java
Extracts board config file resolution into resolveBoardConfigFiles(), updates argument generation, and makes resolvability depend on non-empty config files.
OpenOCD debug launch validation and status handler
bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml, .../dsf/LaunchConfigurationDelegate.java, .../ui/BoardNotSelectedStatusHandler.java, .../ui/Messages.java, .../ui/messages.properties
Registers status code 6001, aborts debug launch when no board is configured, and routes the status to a confirmation handler that opens the active launch target editor.
Serial JTAG flash launch validation
bundles/com.espressif.idf.launch.serial.core/.../SerialFlashLaunchConfigDelegate.java, .../Messages.java, .../messages.properties
Adds board checks and an early return before JTAG flashing, with a confirmation dialog that opens the default launch target editor.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant LaunchConfigurationDelegate
  participant JtagVariableResolver
  participant BoardNotSelectedStatusHandler
  participant ILaunchTargetUIManager

  User->>LaunchConfigurationDelegate: start debug launch
  LaunchConfigurationDelegate->>JtagVariableResolver: isBoardConfigResolvable()
  JtagVariableResolver-->>LaunchConfigurationDelegate: board configuration unavailable
  LaunchConfigurationDelegate->>BoardNotSelectedStatusHandler: handleStatus(6001)
  BoardNotSelectedStatusHandler->>User: show board-not-selected dialog
  User-->>BoardNotSelectedStatusHandler: confirm
  BoardNotSelectedStatusHandler->>ILaunchTargetUIManager: editLaunchTarget(active target)
Loading

Possibly related PRs

Suggested reviewers: kolipakakondal, andriifilippov

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: replacing the confusing program_esp_bins failure with a clearer no-board-selected error message.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch IEP-1772

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sigmaaa

sigmaaa commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

After further thought, I went with failing early via a pop-up instead. It avoids waiting for and parsing every OpenOCD message, and it's more accurate: invalid command name "program_esp_bins" can stem from a corrupted configuration file too, not just an unselected board.

image

Also added the same check for jtag flashing

@sigmaaa sigmaaa added this to the v4.4.0 milestone Jun 18, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java`:
- Around line 618-631: Extract the board-selection validation currently embedded
in checkBinaryDetails() into a reusable check, then invoke it whenever the
server is started, before branching on attach versus non-attach launches. Ensure
attach launches with local OpenOCD enabled also call isBoardConfigured(config)
and report the existing BOARD_NOT_SELECTED_STATUS_CODE status before starting
the server, while preserving the current behavior for other launch paths.
- Around line 652-657: Normalize path separators in the resolved manual
board-configuration options before checking for the “board/” marker. Apply this
change in LaunchConfigurationDelegate around Configuration.resolveAll and in
SerialFlashLaunchConfigDelegate around the resolved value, preserving the
existing detection behavior while accepting Windows backslash paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d6ed08a-81db-4edc-983e-4f0849f42d14

📥 Commits

Reviewing files that changed from the base of the PR and between da497a3 and 060ef20.

📒 Files selected for processing (9)
  • bundles/com.espressif.idf.core/src/com/espressif/idf/core/variable/JtagVariableResolver.java
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/BoardNotSelectedStatusHandler.java
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/Messages.java
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties
  • bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/internal/Messages.java
  • bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/internal/SerialFlashLaunchConfigDelegate.java
  • bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/internal/messages.properties

Comment on lines +618 to +631
// Abort early with a clear, actionable message when no board is selected for the active target. Otherwise
// OpenOCD would start without a board configuration and fail later with the cryptic
// "invalid command name \"program_esp_bins\"" error.
if (!isBoardConfigured(config))
{
IStatus status = new Status(IStatus.OK, Activator.PLUGIN_ID, BOARD_NOT_SELECTED_STATUS_CODE,
"No board is selected for the debug target.", null); //$NON-NLS-1$
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
if (handler != null)
{
handler.handleStatus(status, null);
}
throw new DebugException(Status.OK_STATUS);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Validate board selection for attach launches too.

checkBinaryDetails() is called only under if (!attach) (Lines 339-340). An attach launch with “Start OpenOCD locally” enabled therefore bypasses this guard and can still start OpenOCD without a board configuration. Extract this check and run it whenever the server is started, before the attach branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java`
around lines 618 - 631, Extract the board-selection validation currently
embedded in checkBinaryDetails() into a reusable check, then invoke it whenever
the server is started, before branching on attach versus non-attach launches.
Ensure attach launches with local OpenOCD enabled also call
isBoardConfigured(config) and report the existing BOARD_NOT_SELECTED_STATUS_CODE
status before starting the server, while preserving the current behavior for
other launch paths.

Comment on lines +652 to +657
// Fall back to inspecting the resolved Config options for a manually configured board file.
try
{
String resolvedOptions = Configuration.resolveAll(Configuration.getGdbServerOtherConfig(config), config);
return resolvedOptions != null && resolvedOptions.contains("board/"); //$NON-NLS-1$
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Accept Windows paths in manual board-config detection.

Both fallbacks require the literal board/. A valid manually configured Windows path such as ...\board\esp32.cfg is treated as unconfigured and blocked. Normalize separators before matching.

  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java#L652-L657: normalize resolvedOptions before checking for board/.
  • bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/internal/SerialFlashLaunchConfigDelegate.java#L297-L305: normalize resolved before checking for board/.
Proposed fix
- return resolvedOptions != null && resolvedOptions.contains("board/");
+ return resolvedOptions != null
+         && resolvedOptions.replace('\\', '/').contains("board/");
- return resolved != null && resolved.contains("board/");
+ return resolved != null && resolved.replace('\\', '/').contains("board/");
📝 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
// Fall back to inspecting the resolved Config options for a manually configured board file.
try
{
String resolvedOptions = Configuration.resolveAll(Configuration.getGdbServerOtherConfig(config), config);
return resolvedOptions != null && resolvedOptions.contains("board/"); //$NON-NLS-1$
}
// Fall back to inspecting the resolved Config options for a manually configured board file.
try
{
String resolvedOptions = Configuration.resolveAll(Configuration.getGdbServerOtherConfig(config), config);
return resolvedOptions != null
&& resolvedOptions.replace('\\', '/').contains("board/"); //$NON-NLS-1$
}
📍 Affects 2 files
  • bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java#L652-L657 (this comment)
  • bundles/com.espressif.idf.launch.serial.core/src/com/espressif/idf/launch/serial/internal/SerialFlashLaunchConfigDelegate.java#L297-L305
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java`
around lines 652 - 657, Normalize path separators in the resolved manual
board-configuration options before checking for the “board/” marker. Apply this
change in LaunchConfigurationDelegate around Configuration.resolveAll and in
SerialFlashLaunchConfigDelegate around the resolved value, preserving the
existing detection behavior while accepting Windows backslash paths.

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