Azure / Azure/azure-dev

[layers] azd hooks run does not discover V2 layer hooks

Open
#9,998 0 comments 0 reactions 1 assignee Claimed by @richardpark-msft View on GitHub
area/hooks area/layered-provisioning bug
Dominant language
Go
Stars
569
Forks
364
Avg merge
2d 19h
Merged PRs (30d)
136

Description

## Description

Top-level V2 `layers` are stored in `ProjectConfig.Layers`, but `hooksRunAction` still validates, filters, and executes layer hooks through the legacy `ProjectConfig.Infra` model:

- `--layer` validation calls `projectConfig.Infra.GetLayer(...)`.
- Layer hook execution and validation iterate `projectConfig.Infra.Layers`.

For a V2 project, `ProjectConfig.Infra.Layers` is empty. As a result:

- `azd hooks run preprovision --layer ` cannot resolve a valid V2 layer.
- Running hooks without `--layer` silently skips hooks declared on V2 infrastructure entries.

## Expected behavior

`azd hooks run` should discover infrastructure entries and their hooks through the format-independent project model so V1 `infra.layers` and V2 top-level `layers` behave consistently.

## Suggested validation

Add an offline functional test modeled after `Test_CLI_Hooks_Run_RegistrationAndRun`. The test should spawn the real `azd` binary against a V2 fixture, run `azd hooks run preprovision --layer `, and assert the layer hook writes to the trace file.

## Scope

This is a follow-up issue. It is intentionally **not fixed by #9913 or by any PR in its current stack**.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.