Skip to content

Runtime validation in HooksManager #7443

Description

@wbreza

Runtime Validation in HooksManager

Part of #7435 — Multi-Language Hook Support

User Story

As a template consumer, I want to get a clear error message immediately if my system is missing Python (or another required runtime) rather than waiting until hook execution fails deep in the deployment.

Solution Approach

Modify pkg/ext/hooks_manager.go:

  1. Add ValidateLanguageRuntimes(ctx context.Context, hooks map[string][]*HookConfig) []error:
    • Iterate all hook configs.
    • For each language hook, check runtime availability via executor's Prepare() dry-run or a lightweight CheckInstalled().
    • Cache results per language within a single validation pass (don't check Python N times).
    • Collect all errors — report all missing runtimes at once.
    • Return empty slice when all runtimes available.
  2. This is soft validation — informational at startup (e.g., during azd init or start of azd provision). The hard error remains in Prepare() at execution time.
  3. Surface via ErrorWithSuggestion with install URLs from ExternalTool.InstallUrl().
  4. Must handle both project-level and service-level hooks (learned from PowerShell 7 suggestion text not showing for service-level hooks #5453).

Modify pkg/ext/hooks_manager_test.go:

  • Python available → no errors
  • Python missing → error with install suggestion
  • Multiple languages missing → all errors collected
  • Duplicate language hooks → check cached (only one Python check)

Files: pkg/ext/hooks_manager.go (MODIFY), pkg/ext/hooks_manager_test.go (MODIFY)

Acceptance Criteria

  • ValidateLanguageRuntimes returns errors for each missing runtime
  • Caches per language — no duplicate checks
  • Returns empty slice when all runtimes available
  • Does not block hook resolution (informational only)
  • Error messages use ErrorWithSuggestion with platform-specific install URLs

References

Metadata

Metadata

Assignees

Labels

area/core-cliCLI commands, cmd/, internal/cmd/area/hooksLifecycle hooksfeatureFeature request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions