Skip to content

Conversation

Copy link

Copilot AI commented Oct 15, 2025

Problem

On restricted network environments such as UsGov systems, Power Pages generator installation was failing silently. Users would see "Installing Power Pages generator..." message but npm would fail without proper error detection or user feedback, leaving the generator uninstalled and commands unavailable.

Root Cause

The GeneratorAcquisition.ensureInstalled() method only checked child.error from spawnSync, but on restricted networks npm could fail with a non-zero exit code without setting the error object. This caused:

  1. npm install failures going undetected
  2. No error messages shown to users
  3. Generator remaining uninstalled (yoCommandPath null)
  4. Commands not being registered (as designed - generator is required)
  5. Users having no feedback about what went wrong

Solution

Enhanced Error Detection (GeneratorAcquisition.ts)

Now checks both child.error AND child.status for npm install failures:

// Before: Only checked child.error
if (child.error) { ... }

// After: Checks both error object and exit code
if (child.error || child.status !== 0) {
    const errorMessage = child.error 
        ? String(child.error) 
        : `npm install exited with code ${child.status}`;
    // ... improved error handling with exit code in telemetry
}

This ensures:

  • npm failures are properly detected even when error object is not set
  • Users see clear error messages about installation failures
  • Exit codes are logged in telemetry for diagnostics
  • Commands remain unregistered when installation fails (generator is required for commands to work)

Impact

Better error detection: Properly detects npm failures on restricted networks
Better diagnostics: Exit codes logged in telemetry for troubleshooting
Clear user feedback: Users see error messages when installation fails
Backwards compatible: No changes to command registration logic
Works on restricted networks: Properly handles npm failures on UsGov systems

Behavior

  1. On successful installation: Commands register and work as before
  2. On failed installation:
    • Error is now properly detected and logged
    • Clear error message shown to user with exit code
    • Commands are NOT registered (generator is required for commands to work)
    • User can troubleshoot based on error message

Fixes #1338

Original prompt

This section details on the original issue you should resolve

<issue_title>All Powerpages commands such as 'microsoft-powerapps-portals.webpage' not Registered during installation on UsGov systems</issue_title>
<issue_description>When installing the Power Platform Tools extension on VS Code on a stricter system, commands for working with Power Pages Actions such as creating a new webpage or content snipper all give the same error that the command is not found. Appears that the commands are not registered in the command palette during installation. Tried uninstalling/reinstalling extension and VSCode.

Power Pages generator keeps showing installing v1.21.19

Microsoft PowerPlatform CLI
Version: 1.49.4+g406813e (.NET Framework 4.8.9310.0)

npm: '11.6.0',
node: '24.9.0'</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1338


💡 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.

- Commands now register even if generator installation fails
- Added proper exit code checking for npm install
- Added retry mechanism with user-friendly error messages
- Added test coverage for command registration behavior
- Improved error handling and telemetry logging

Co-authored-by: amitjoshi438 <[email protected]>
Copilot AI changed the title [WIP] Fix registration of Power Pages commands on UsGov systems Fix Power Pages commands not registered on restricted networks (UsGov systems) Oct 15, 2025
Copilot AI requested a review from amitjoshi438 October 15, 2025 06:08
Copilot finished work on behalf of amitjoshi438 October 15, 2025 06:08
@amitjoshi438
Copy link
Contributor

@copilot we don't want to register command if generator installation fails, generator is required for commands to work

Per feedback, commands should NOT register if generator installation fails.
Reverted CreateCommandWrapper.ts to original behavior where commands only
register when generator is successfully installed.

Kept the improved error detection in GeneratorAcquisition.ts which properly
checks npm exit codes (child.status !== 0) in addition to child.error.
This ensures installation failures are properly detected and reported on
restricted networks like UsGov systems.

Co-authored-by: amitjoshi438 <[email protected]>
Copy link
Author

Copilot AI commented Oct 15, 2025

@copilot we don't want to register command if generator installation fails, generator is required for commands to work

You're absolutely right. I've reverted the command registration changes. Commands will NOT be registered if generator installation fails, as the generator is required for them to work.

The fix now only improves error detection in GeneratorAcquisition.ts by checking both child.error AND child.status !== 0. This ensures npm installation failures on restricted networks are properly detected and reported to users, while maintaining the original behavior where commands only register when installation succeeds.

Changes in commit: git show --stat HEAD (will show after commit completes)

Copilot AI changed the title Fix Power Pages commands not registered on restricted networks (UsGov systems) Fix Power Pages generator installation error detection on restricted networks (UsGov systems) Oct 15, 2025
Copilot finished work on behalf of amitjoshi438 October 15, 2025 09:50
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.

All Powerpages commands such as 'microsoft-powerapps-portals.webpage' not Registered during installation on UsGov systems

2 participants