Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Summary

When resolving the home directory in remote environments, shells that echo executed commands (e.g., set -x) cause output containing multiple instances of the marker strings. The parser was extracting from the first occurrence instead of the actual command output.

Details

Changed marker parsing from indexOf() to lastIndexOf() to extract from the final occurrence:

// Before: Extracts from first marker pair (echoed command text)
const startIndex: number = output.indexOf(markerPrefix);
const endIndex: number = output.indexOf(markerSuffix);

// After: Extracts from last marker pair (actual output)
const startIndex: number = output.lastIndexOf(markerPrefix);
const endIndex: number = output.lastIndexOf(markerSuffix);
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {

Added validation that end marker follows start marker to handle malformed output.

Bumped the package version from 0.0.6 to 0.0.7 as version bumping for VSCode extensions is not automatic.

How it was tested

Created test scripts simulating shell echo scenarios:

  • Verified indexOf() incorrectly extracts command text when shell echoes
  • Verified lastIndexOf() correctly extracts home directory with echo enabled
  • Verified backward compatibility with shells that don't echo
  • Validated edge cases: unbalanced markers, multiple pairs

Impacted documentation

None.

Original prompt

In the debug certificate manager VSCode Extension, when looking for the home directory, some shells echo the command being executed before executing it. The output processor should therefore look for the last instance of the markers, rather than the first.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 10, 2025
Copilot AI and others added 2 commits December 10, 2025 02:08
…ility

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix output processor to find last instance of markers [debug-certificate-manager] Fix home directory parsing for shells that echo commands Dec 10, 2025
Copilot AI requested a review from dmichon-msft December 10, 2025 02:14
@dmichon-msft
Copy link
Contributor

@copilot Also make a patch bump to the affected vscode extension package version, since version bumping of vscode extensions is not automatic.

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 10, 2025

@copilot Also make a patch bump to the affected vscode extension package version, since version bumping of vscode extensions is not automatic.

Done. Bumped version from 0.0.6 to 0.0.7 in commit 7cd82c0.

@dmichon-msft dmichon-msft marked this pull request as ready for review December 12, 2025 06:20
@bmiddha bmiddha merged commit b9d4c9b into main Dec 12, 2025
8 checks passed
@bmiddha bmiddha deleted the copilot/fix-output-processor-markers branch December 12, 2025 08:30
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants