Bug Description
When a hook configuration has both dir and run fields set and no explicit kind, the hook kind inference fails to detect the correct executor. On Windows this causes hooks to default to PowerShell and look for a .ps1 file, even when the actual script is Python, JavaScript, TypeScript, Bash, or C#.
Steps to Reproduce
- Configure
azure.yaml with a service hook using both dir and run:
hooks:
preprovision:
dir: hooks/preprovision
run: main.py
- Run
azd provision on Windows
Expected Behavior
The hook system should infer kind: python from the .py extension on the run field and execute with the Python executor.
Actual Behavior
The hook defaults to PowerShell and fails looking for a .ps1 file. Error: script with file extension '' is not valid. unsupported script type.
Root Cause
In pkg/ext/models.go validate(), when dir + run are combined:
hc.path is set to the raw hc.Run value instead of the resolved filename found via os.Stat
InferKindFromPath receives hc.Run instead of the actual file path with extension
- Kind inference fails and defaults to
defaultKindForOS() (PowerShell on Windows)
Affected Hook Kinds
All non-shell hook kinds are affected when using dir + run without explicit kind:
- Python (
.py)
- JavaScript (
.js)
- TypeScript (
.ts)
- C#/DotNet (
.cs)
- Bash (
.sh) on Windows
Fix
Fix is being implemented in PR #7689 alongside the path boundary fix for #7666.
Bug Description
When a hook configuration has both
dirandrunfields set and no explicitkind, the hook kind inference fails to detect the correct executor. On Windows this causes hooks to default to PowerShell and look for a.ps1file, even when the actual script is Python, JavaScript, TypeScript, Bash, or C#.Steps to Reproduce
azure.yamlwith a service hook using bothdirandrun:azd provisionon WindowsExpected Behavior
The hook system should infer
kind: pythonfrom the.pyextension on therunfield and execute with the Python executor.Actual Behavior
The hook defaults to PowerShell and fails looking for a
.ps1file. Error:script with file extension '' is not valid. unsupported script type.Root Cause
In
pkg/ext/models.govalidate(), whendir+runare combined:hc.pathis set to the rawhc.Runvalue instead of the resolved filename found viaos.StatInferKindFromPathreceiveshc.Runinstead of the actual file path with extensiondefaultKindForOS()(PowerShell on Windows)Affected Hook Kinds
All non-shell hook kinds are affected when using
dir+runwithout explicitkind:.py).js).ts).cs).sh) on WindowsFix
Fix is being implemented in PR #7689 alongside the path boundary fix for #7666.