| name | deployment-error-fixer |
| description | Autonomously detect and fix logic errors in Python and Bicep deployment code for the AOS infrastructure. Handles syntax errors, validation failures, and common deployment issues to enable fully autonomous deployment workflows.
USE FOR: fix Python syntax errors, fix Bicep BCP errors, resolve deployment logic failures, fix missing imports, fix parameter validation errors, auto-repair deployment code, pre-deployment validation, lint → validate → what-if → deploy pipeline.
DO NOT USE FOR: environmental deployment failures (retry with backoff instead), infrastructure architecture changes (use azure-prepare), compliance scanning (use azure-compliance), cost analysis (use azure-cost-optimization).
|
| license | MIT |
| metadata | {"author":"ASISaga","version":"2.0","category":"azure-infrastructure","role":"deployment-specialist"} |
| allowed-tools | Bash(az:*) Bash(pylint:*) Bash(python:*) Read Edit |
Deployment Error Fixer Skill
Description
Expert skill for autonomously analyzing and fixing logic errors in deployment code (Python and Bicep). This skill enables the deployment agent to handle not just environmental failures, but also code-level issues without requiring manual developer intervention. It enforces the AOS deployment pipeline: lint → validate → what-if → deploy.
Triggers
Activate this skill when:
- Python linting errors are detected in
deployment/orchestrator/ code
- Python syntax errors occur during deployment execution
- Bicep validation errors (BCP error codes) are found
- Bicep template errors prevent successful deployment
- Parameter validation fails
- Initial deployment attempt fails with logic errors
- Running preflight validation before a deployment
Rules
- Validate before deploying — Always run
pylint + az bicep build + az deployment group what-if before applying changes
- Minimal changes — Fix only the broken code, preserve style and formatting
- Log all fixes — Document what was changed and why in the audit trail
- Safety first — Follow Global Rules for destructive actions
- ⛔ Never auto-fix production security configurations — requires human approval
- ⛔ Destructive actions require user confirmation — Global Rules
Deployment Pipeline (AOS)
The AOS deployment pipeline enforced by this skill:
lint (pylint)
↓
validate (az bicep build)
↓
what-if (az deployment group what-if)
↓
deploy (az deployment group create)
↓
health checks
See Pre-Deploy Checklist for the full validation sequence.
MCP Tools
When Azure MCP is available:
| Tool | Purpose |
|---|
mcp_azure_mcp_subscription_list | Confirm active subscription before deploying |
mcp_azure_mcp_group_list | Verify resource group exists |
mcp_azure_mcp_extension_cli_generate | Generate CLI commands for Bicep fixes |
When to Use This Skill
- When Python linting errors are detected in deployment/orchestrator/ code
- When Python syntax errors occur during deployment execution
- When Bicep validation errors are found (BCP error codes)
- When Bicep template errors prevent successful deployment
- When parameter validation fails
- After initial deployment attempt fails with logic errors
Core Capabilities
1. Python Error Detection and Fixing
Common Python Issues
Syntax Errors:
- Missing colons, parentheses, brackets
- Indentation errors (mix of tabs/spaces)
- Invalid identifiers or keywords
- String quote mismatches
Import Errors:
- Missing imports
- Circular import dependencies
- Incorrect module paths
Type Errors:
- Type hint mismatches
- None type errors
- Attribute access on None
Common Fixes:
def deploy_resource(name)
return name
def deploy_resource(name):
return name
def process():
if True:
return "A"
return "B"
def process():
if True:
return "A"
return "B"
def main():
result = subprocess.run(["ls"])
import subprocess
def main():
result = subprocess.run(["ls"])
2. Bicep Error Detection and Fixing
Common Bicep Error Codes (BCP)
BCP029: Invalid resource type format
// BEFORE: Invalid format
resource storage 'Microsoft.Storage/storageAccounts' = {
...
}
// AFTER: Fixed with API version
resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
...
}
BCP033: Expected value of type X but got Y
// BEFORE: Type mismatch
param instanceCount int = '3' // String instead of int
// AFTER: Fixed
param instanceCount int = 3
BCP037: Property X is not allowed
// BEFORE: Invalid property
resource vm 'Microsoft.Compute/virtualMachines@2023-03-01' = {
name: 'myvm'
location: 'eastus'
invalidProperty: 'value' // Not allowed
}
// AFTER: Fixed (removed invalid property)
resource vm 'Microsoft.Compute/virtualMachines@2023-03-01' = {
name: 'myvm'
location: 'eastus'
}
3. Parameter Validation Errors
Missing Required Parameters:
// main-modular.bicep requires: environment, location, projectName
// BEFORE: Missing parameters
az deployment group create \
--resource-group my-rg \
--template-file main-modular.bicep
// AFTER: Fixed with all required parameters
az deployment group create \
--resource-group my-rg \
--template-file main-modular.bicep \
--parameters environment=dev location=eastus projectName=aos
Autonomous Fix Decision Tree
Error Detected
↓
Is it a known pattern?
↓ YES ↓ NO
Apply fix automatically Extract error details
↓ ↓
Verify fix doesn't break other code Is it critical (prod)?
↓ ↓ YES ↓ NO
Re-run validation Ask human Try fix
↓ ↓ ↓
Success? Wait Re-validate
↓ YES ↓ NO ↓
Continue Report & halt Success?
↓ YES ↓ NO
Continue Report
Error Analysis Process
Step 1: Detect Error Type
ERROR_TYPE=""
if echo "$ERROR" | grep -q "error BCP"; then
ERROR_TYPE="bicep_validation"
BCP_CODE=$(echo "$ERROR" | grep -oE "BCP[0-9]+")
elif echo "$ERROR" | grep -q "SyntaxError\|IndentationError"; then
ERROR_TYPE="python_syntax"
elif echo "$ERROR" | grep -q "ImportError\|ModuleNotFoundError"; then
ERROR_TYPE="python_import"
elif echo "$ERROR" | grep -q "invalid.*parameter\|missing.*parameter"; then
ERROR_TYPE="parameter_validation"
fi
Step 2: Extract Context
FILE=$(echo "$ERROR" | grep -oP '(?<=File ")[^"]+')
LINE=$(echo "$ERROR" | grep -oP '(?<=line )[0-9]+')
if [[ -f "$FILE" ]]; then
START=$((LINE - 3))
END=$((LINE + 3))
CONTEXT=$(sed -n "${START},${END}p" "$FILE")
fi
Step 3: Apply Fix
For Bicep errors:
if [[ "$BCP_CODE" == "BCP029" ]]; then
RESOURCE_TYPE=$(echo "$ERROR_DETAILS" | grep -oP "Microsoft\.[^']+")
LATEST_VERSION=$(az provider show \
--namespace ${RESOURCE_TYPE%%/*} \
--query "resourceTypes[?resourceType=='${RESOURCE_TYPE##*/}'].apiVersions[0]" \
-o tsv)
sed -i "s|'${RESOURCE_TYPE}'|'${RESOURCE_TYPE}@${LATEST_VERSION}'|" "$FILE"
fi
For Python errors:
if [[ "$ERROR_TYPE" == "python_import" ]]; then
MODULE=$(echo "$ERROR" | grep -oP "(?<=No module named ')[^']+")
echo "import ${MODULE}" | cat - "$FILE" > temp && mv temp "$FILE"
fi
Safety Constraints
Never Auto-Fix
- Changes to production parameter files
- Modifications to security-related resources (Key Vault, RBAC)
- Deletion or renaming of resources
- Changes to networking (VNET, NSG, firewall rules)
- Database connection strings or credentials
Always Ask Before Fixing
- Changes affecting > 5 files
- Modifications to main-modular.bicep architecture
- API version upgrades (may introduce breaking changes)
- Parameter value changes in production
Auto-Fix Allowed
- Syntax errors (missing colons, parentheses)
- Indentation fixes
- Missing imports (from same repo)
- BCP error codes for invalid syntax
- Type mismatches in parameters
- Missing required parameters (use defaults)
- Typos in function names
- Read-only property removal
Example Scenarios
Scenario 1: Bicep BCP029 Error
Input:
Error: BCP029: The resource type is not valid.
File: deployment/modules/storage.bicep, Line: 5
Fix Applied:
// Before
resource storage 'Microsoft.Storage/storageAccounts' = {
// After
resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
Outcome: ✅ Auto-fixed, deployment retried
Scenario 2: Python Import Error
Input:
ImportError: No module named 'pathlib'
File: deployment/orchestrator/cli/deploy.py, line 5
Outcome: ✅ Classified correctly, appropriate action taken
Scenario 3: Missing Parameter
Input:
Error: Missing required parameter: projectName
File: deployment/parameters/dev.bicepparam
Fix Applied:
// Before
using './main-modular.bicep'
param environment = 'dev'
param location = 'eastus'
// After
using './main-modular.bicep'
param environment = 'dev'
param location = 'eastus'
param projectName = 'aos' // Added with sensible default
Outcome: ✅ Auto-fixed, deployment retried
Best Practices
- Always validate before fixing: Understand the error completely
- Use minimal changes: Fix only what's broken
- Preserve formatting: Match existing code style
- Test after fixing: Re-run validation immediately
- Log all fixes: Document what was changed and why
- Ask when uncertain: Better to ask than break production
Error Patterns Database
Python Common Patterns
| Pattern | Fix | Auto? |
|---|
Missing : in function def | Add : | ✅ Yes |
| Indentation mix (tabs/spaces) | Convert to spaces | ✅ Yes |
| Missing import | Add import line | ✅ Yes |
| Undefined variable | Check scope, add declaration | ⚠️ Ask |
| Type hint error | Fix or remove hint | ✅ Yes |
Bicep Common Patterns
| BCP Code | Issue | Fix | Auto? |
|---|
| BCP029 | Missing API version | Add @apiVersion | ✅ Yes |
| BCP033 | Type mismatch | Cast or change type | ✅ Yes |
| BCP037 | Invalid property | Remove property | ✅ Yes |
| BCP051 | Missing keyword | Add resource/param/var | ✅ Yes |
| BCP062 | Invalid function | Correct function name | ✅ Yes |
| BCP073 | Read-only property | Remove property | ✅ Yes |
Summary
This skill enables the deployment agent to:
- ✅ Detect Python and Bicep logic errors
- ✅ Analyze error context and patterns
- ✅ Apply automatic fixes for common issues
- ✅ Validate fixes before re-attempting deployment
- ✅ Enforce the lint → validate → what-if → deploy pipeline
- ✅ Ask for help when uncertain
- ✅ Maintain safety constraints for critical changes
Related Documentation