Skip to content

Commit 22e3dcb

Browse files
authored
Merge pull request #238 from microsoft/users/ansjain/PluginFixes
fix(plugin): add pac 2.3.2 version check and improve auth error handling
2 parents 2955e89 + ca1a3f2 commit 22e3dcb

File tree

6 files changed

+57
-12
lines changed

6 files changed

+57
-12
lines changed

plugin/power-apps-plugin/agents/code-app-architect.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ When consulted, you provide guidance on:
3737
Verify prerequisites before proceeding with any implementation work:
3838

3939
```bash
40-
node --version # Must be v22+
41-
pwsh -NoProfile -Command "pac" # Windows executable — must use pwsh
40+
node --version # Must be v22+
41+
pwsh -NoProfile -Command "pac" # Windows executable — must use pwsh; also check Version: line in output — must NOT be 2.3.2
4242
```
4343

4444
- **Node.js below v22**: Report "Node.js 22+ is required. Upgrade or switch with `nvm use 22`." and STOP.
4545
- **Missing @microsoft/power-apps-cli**: Report "Install with `npm install -g @microsoft/power-apps-cli`." and STOP.
4646
- **Missing pac**: Report "Install Power Platform CLI from https://aka.ms/PowerAppsCLI." and STOP.
47-
- **All present**: Report versions and proceed.
47+
- **pac version is 2.3.2**: This version has a known bug (`TypeError: Cannot read properties of undefined (reading 'httpClient')`) that causes `pac code push` to fail. Try upgrading: `npm install -g @microsoft/power-apps-cli`. If the upgraded version is still 2.3.2, install the known-good fallback instead: `npm install -g @microsoft/power-apps-cli@2.2.1`. Confirm user approval before any global install per shared instructions.
48+
- **All present and not 2.3.2**: Report versions and proceed.
4849

4950
## Key Considerations for Power Apps Code Apps
5051

plugin/power-apps-plugin/shared/shared-instructions.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,36 @@ When selecting an environment, use this priority order: `power.config.json` →
117117

118118
---
119119

120+
## pac Version Check
121+
122+
**pac version 2.3.2 has a known bug where `pac code push` fails with `TypeError: Cannot read properties of undefined (reading 'httpClient')`. Never use this version.**
123+
124+
After confirming `pac` is installed, always check its version. `pac --version` is not a valid flag, but running `pac` with no arguments prints the version in the output header:
125+
126+
```bash
127+
pwsh -NoProfile -Command "pac"
128+
```
129+
130+
Look for the `Version:` line in the output (e.g., `Version: 2.3.2+...`).
131+
132+
### If version is 2.3.2:
133+
134+
1. **Try upgrading first** (ask user confirmation per global install rule):
135+
```bash
136+
npm install -g @microsoft/power-apps-cli
137+
```
138+
2. **Verify the upgrade** by re-running `pwsh -NoProfile -Command "pac"` and checking the `Version:` line.
139+
3. **If still on 2.3.2** (it is the latest available), install the known-good older version instead:
140+
```bash
141+
npm install -g @microsoft/power-apps-cli@2.2.1
142+
```
143+
144+
### If version is anything other than 2.3.2:
145+
146+
Proceed normally — no action needed.
147+
148+
---
149+
120150
## Windows CLI Compatibility
121151

122152
The shell running Bash tool commands is bash on Windows. The `pac` CLI is a Windows executable and is **not** on the bash PATH.

plugin/power-apps-plugin/skills/create-power-app/SKILL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ git --version # Optional but recommended
3939
Check `pac` CLI via PowerShell — it's a Windows executable not on the bash PATH:
4040

4141
```bash
42-
pwsh -NoProfile -Command "pac" # Used for auth, env selection, code commands
42+
pwsh -NoProfile -Command "pac" # Used for auth, env selection, code commands; also check Version: line in output — must NOT be 2.3.2
4343
```
4444

4545
- **Missing Node.js**: Report "Install Node.js v22+ from https://nodejs.org/" and STOP.
4646
- **Node.js below v22**: Report "Node.js 22+ is required. Please upgrade or switch with `nvm use 22`." and STOP.
4747
- **Missing pac**: Report "Install Power Platform CLI from https://aka.ms/PowerAppsCLI" and STOP.
4848
- **Missing Git**: Report "Recommended but optional." Continue if approved.
49-
- **All present**: Report versions and proceed.
49+
- **pac version is 2.3.2**: This version has a known bug (`TypeError: Cannot read properties of undefined (reading 'httpClient')`) that causes `pac code push` to fail. Try upgrading: `npm install -g @microsoft/power-apps-cli`. If the upgraded version is still 2.3.2, install the known-good fallback instead: `npm install -g @microsoft/power-apps-cli@2.2.1`. Confirm user approval before any global install per shared instructions. STOP until resolved.
50+
- **All present and not 2.3.2**: Report versions and proceed.
5051

5152

5253
### Step 2: Gather Requirements

plugin/power-apps-plugin/skills/create-power-app/references/prerequisites-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Tool | Minimum Version | Check Command | Install |
66
| -------------- | --------------- | -------------------------------- | --------------------------- |
77
| Node.js | **v22+** | `node --version` | https://nodejs.org/ |
8-
| pac CLI | **latest** | `pwsh -NoProfile -Command "pac"` | https://aka.ms/PowerAppsCLI |
8+
| pac CLI | **latest, not 2.3.2** | `pwsh -NoProfile -Command "pac"` (check `Version:` line) | https://aka.ms/PowerAppsCLI |
99
| Git (optional) | Any | `git --version` | https://git-scm.com/ |
1010

1111
```bash

plugin/power-apps-plugin/skills/create-power-app/references/troubleshooting.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414
| ----------------------- | ------------------------------------------------------------------ |
1515
| Build fails | Check Node.js LTS version, run `npm install` |
1616
| Build fails with TS6133 | Unused imports cause errors in strict mode. Remove unused imports. |
17-
| Auth error | Run `pwsh -NoProfile -Command "pac auth clear" && pwsh -NoProfile -Command "pac auth create"` |
17+
| Auth error | Run `pwsh -NoProfile -Command "pac auth list"` to check auth state. If authenticated but wrong environment, run `pwsh -NoProfile -Command "pac env select --environment <id>"`. Only if that fails, run `pwsh -NoProfile -Command "pac auth create"`. |
1818
| No data | Verify user has read access to table, check browser console |
1919
| Local testing | Use same browser profile as Power Platform auth |
2020

2121
## Deploy Errors
2222

2323
| Error | Fix |
2424
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25-
| "environment config does not match" | Ask the user: **retarget the app** (update `environmentId` in `power.config.json` to match active env) or **switch auth** (run `pwsh -NoProfile -Command "pac auth create"` to match the app's environment). Then retry. |
25+
| "environment config does not match" | Run `pwsh -NoProfile -Command "pac auth list"` to check active environment. Then either: **re-target the app** (update `environmentId` in `power.config.json` to match active env), or **switch environment** (`pwsh -NoProfile -Command "pac env select --environment <id>"`). Only if switching environment fails, run `pwsh -NoProfile -Command "pac auth create"`. |
2626
| DNS/network error | Try different environment or contact admin. |
2727
| Auth error | Run `pwsh -NoProfile -Command "pac auth create"` and retry. |
2828
| Auth error on macOS (pac bug) | `pac` has known auth bugs on Mac. Use the npx CLI instead: run `npm install -g @microsoft/power-apps-cli` (skip if already installed), then `npx power-apps push`. |
29+
| `TypeError: Cannot read properties of undefined (reading 'httpClient')` | Caused by pac version 2.3.2. Try upgrading: `npm install -g @microsoft/power-apps-cli`. If the version is still 2.3.2, install the known-good fallback: `npm install -g @microsoft/power-apps-cli@2.2.1`. |
2930

3031
## Resources
3132

plugin/power-apps-plugin/skills/deploy/SKILL.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,22 @@ pac code push
4343

4444
Capture the app URL from the output if present.
4545

46-
If deploy fails, report the error and stop — do not retry silently. Common fixes are in the troubleshooting guide:
47-
48-
- Auth error → `pwsh -NoProfile -Command "pac auth create"`
49-
- Environment mismatch → `pwsh -NoProfile -Command "pac env select --environment <id>"`
46+
If deploy fails, report the error and follow this diagnostic sequence — do not retry silently:
47+
48+
1. **Always run `pac auth list` first** to check authentication state and which environment is active:
49+
```bash
50+
pwsh -NoProfile -Command "pac auth list"
51+
```
52+
2. **If authenticated but targeting the wrong environment**: switch environment and retry:
53+
```bash
54+
pwsh -NoProfile -Command "pac env select --environment <correct-environment-id>"
55+
pwsh -NoProfile -Command "pac code push"
56+
```
57+
3. **If `pac env select` fails, or pac is not authenticated at all**: then run:
58+
```bash
59+
pwsh -NoProfile -Command "pac auth create"
60+
pwsh -NoProfile -Command "pac code push"
61+
```
5062

5163
**Mac fallback — if `pac code push` fails with an auth error on macOS:**
5264
`pac` has known authentication bugs on Mac that can block the push. Use the npx CLI instead:

0 commit comments

Comments
 (0)