| name | fix-codeapp-issue |
| description | Troubleshoot and fix common Power Apps Code Apps issues including deployment errors, 404 asset errors, Dataverse OData errors, authentication issues, and build failures. Provides diagnostic guidance and automated fixes. |
| disable-model-invocation | false |
| allowed-tools | Read, Write, Edit, Bash, Grep, Glob, Skill |
Fix Code Apps Issues
Diagnose and fix common Power Apps Code Apps issues with guided troubleshooting and automated repairs.
What This Skill Does
- Diagnoses common CodeApps issues based on symptoms
- Provides step-by-step troubleshooting guidance
- Attempts automated fixes when possible
- Validates fixes with integrated validation
- Provides prevention tips
Common Issues & Solutions
Issue 1: 404 Errors for Assets (Blank Screen After Deployment)
Symptoms:
- Deployed app shows blank screen
- Console shows:
GET .../assets/index-xxx.js net::ERR_ABORTED 404
- MIME type error:
Refused to apply style ... MIME type ('application/json')
Root Cause: Missing base: './' in vite.config.ts
Automated Fix:
const config = await read('vite.config.ts');
if (!config.includes("base: './'")) {
const updated = config.replace(
'export default defineConfig({',
`export default defineConfig({\n base: './',`
);
await write('vite.config.ts', updated);
console.log('✅ Added base: "./" to vite.config.ts');
await exec('npm run build');
console.log('💡 Run: pac code push');
}
Issue 2: System-Managed Field Error (Dataverse)
Symptoms:
PrimitiveValue node with non-null value was found... 'ownerid'
- Create/update operations fail
Root Cause: Sending system-managed fields (ownerid, statecode, timestamps, primary key)
Fix: Review service layer and remove system-managed fields:
const payload = {
name: dto.name,
ownerid: '',
statecode: 0,
};
const payload = {
name: dto.name,
};
Issue 3: Boolean Field Type Mismatch
Symptoms:
Cannot convert the literal '1' to expected type 'Edm.Boolean'
- Update operations fail with Boolean fields
Root Cause: Generated types suggest numeric (0|1) but Dataverse expects boolean
Fix: Use as any type assertion:
updates.booleanField = value ? 1 : 0;
updates.booleanField = value as any;
Issue 4: Authentication Failures
Symptoms:
pac code push fails with authentication error
- Connector API calls return 401
Fix:
pac auth clear
pac auth create
pac env select --environment <environmentId>
Issue 5: Build Failures
Symptoms:
npm run build exits with errors
- TypeScript compilation errors
Diagnostic Steps:
- Read build output for specific errors
- Check for missing imports
- Verify dependencies installed:
npm install
- Run TypeScript check:
npx tsc --noEmit
- Run ESLint:
npm run lint
Common Causes:
- Missing dependencies
- Import path errors
- Type mismatches
- Unused variables
Issue 6: Connection Not Found
Symptoms:
pac code add-data-source fails
- API calls fail with connection errors
Fix:
pac connection list
echo "Create connection at: https://make.powerapps.com → Connections"
Issue 7: Port Conflicts
Symptoms:
npm run dev fails with "port already in use"
Fix:
netstat -ano | findstr :5173
lsof -i :5173
Issue 8: pac code init Failures
Symptoms:
pac code init fails
- power.config.json not created
Fix:
pac auth list
pac auth create
pac env select --environment <environmentId>
pac code init --displayName "AppName"
Diagnostic Workflow
Step 1: Identify Issue Category
Ask user about symptoms:
- Deployment issues (404s, blank screen)
- Data operation failures (Dataverse/connector errors)
- Build/compilation failures
- Authentication problems
- Development environment issues
Step 2: Run Diagnostics
Based on category, run appropriate checks:
For Deployment Issues:
cat vite.config.ts | grep "base:"
cat dist/index.html | grep -E 'src=|href='
cat power.config.json
For Data Issues:
- Review service layer for system-managed fields
- Check Boolean field handling
- Verify connection exists:
pac connection list
For Build Issues:
Invoke codeapps-validator skill
Invoke build-lint-validator skill
Step 3: Apply Fixes
Attempt automated fixes when possible:
- Add missing
base: './'
- Fix import paths
- Remove system-managed fields from payloads
- Add
as any to Boolean fields
Step 4: Validate Fix
npm run build
Invoke codeapps-validator skill
npm run dev
Step 5: Prevention Guidance
Provide tips to avoid future issues:
- Always use codeapps-validator before deployment
- Never modify src/generated/ files
- Use service layer wrappers (never call generated services directly)
- Test in local dev before deploying
- Use connection references for better ALM
Quick Diagnosis Commands
Invoke codeapps-validator skill
npm run build
npm run lint
pac auth list
pac connection list
pac code list
cat vite.config.ts | grep "base:"
cat dist/index.html | grep -E 'src=|href='
Output Format
🔍 Diagnostic Report
❌ Issues Found:
1. [Issue description]
- Cause: [root cause]
- Impact: [what's affected]
🔧 Applied Fixes:
1. [Fix applied]
- File: [file path]
- Change: [what changed]
✅ Validation:
- Build: Pass/Fail
- TypeScript: Pass/Fail
- ESLint: Pass/Fail
💡 Prevention Tips:
- [Tip 1]
- [Tip 2]
📋 Next Steps:
1. [Action item]
2. [Action item]
Related Skills
- /init-codeapp: Reinitialize project if severely broken
- /deploy-codeapp: Redeploy after fixes
- codeapps-validator: Comprehensive validation
- build-lint-validator: Build quality check
Usage: Invoke when encountering errors or issues during development, build, or deployment. Provides diagnostic guidance and automated fixes.