Local preflight: warn users when bicep snapshot fails and checks are skipped
- Dominant language
- Go
- Stars
- 569
- Forks
- 364
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 136
Description
## Problem
When `bicep snapshot` fails (e.g., due to templates using non-null assertions `!` on module outputs that cannot be speculatively evaluated), all local preflight checks are silently skipped. Users have no visibility that the AI quota check and other preflight validations did not run.
The current code logs the failure at `log.Printf` level which only shows with `--debug`, but there is no user-facing indication that checks were skipped.
## Root Cause
The Bicep snapshot engine speculatively evaluates template expressions. When a template uses patterns like:
```bicep
principalId: myModule.outputs.systemAssignedMIPrincipalId!
```
The `!` (non-null assertion) fails at snapshot time because module outputs are unknown before deployment. This causes `bicep snapshot` to exit with:
```
Template snapshotting could not be completed for the following reason:
'The provided value for the template parameter ... is not valid.
A non-null value for the property 'principalId' must be provided'
```
This is tracked upstream as [Azure/bicep#18822](https://github.com/Azure/bicep/issues/18822) (still open).
## Expected Behavior
- When `bicep snapshot` fails, show a debug-level log message explaining that preflight checks could not be performed for the template
- The message should be visible when `--debug` is set but not clutter normal output
- Consider including guidance about the upstream limitation
## Related
- Upstream: [Azure/bicep#18822](https://github.com/Azure/bicep/issues/18822)
- Investigation: #7986
Contributor guide
Assessment
This issue has not been assessed yet.