Azure / Azure/bicep-registry-modules
[AVM Module Issue]: policy-assignment emits 12x BCP318 "possible null reference" warnings on the multi-scope output ternary
- Dominant language
- Bicep
- Stars
- 736
- Forks
- 564
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 30
Description
### Module Name
`avm/ptn/authorization/policy-assignment`
### Module Version
`0.5.3` (latest as of 2026-07-13; also reproducible on earlier versions — the ternary output pattern predates 0.5.3)
### Issue Type
Bug
### Description
`main.bicep` resolves its 4 outputs (`name`, `principalId`, `resourceId`, `location`) with a nested ternary that selects between 3 conditional submodules (`policyAssignment_mg`, `policyAssignment_sub`, `policyAssignment_rg` — one per scope, each declared conditionally so its type is `module | null`). The Bicep compiler cannot statically prove that exactly one of the 3 modules is deployed on each ternary branch, and emits `BCP318` ("The value of type 'module | null' may be null...") on every `.outputs.*` access — 12 occurrences in total (3 submodules × 4 outputs; lines 191, 193, 194, 198, 200, 201, 205, 207, 208, 212, 214, 215 in the 0.5.3 source).
**Expected:** building/linting a published AVM module yields 0 warnings for consumers enforcing a standard 0-warning gate. The exclusive-scope ternary pattern could be restructured so the compiler can prove non-nullability, or the diagnostic could be explicitly suppressed in-source with a rationale if it is considered an intentional false positive.
**Actual (0.5.3):** `az bicep build` / `az bicep lint` on `main.bicep` emits 12× `Warning BCP318` (EXIT 0 — non-blocking, but it breaks any consumer-side 0-warnings gate).
**Repro:**
```bash
git clone --filter=blob:none https://github.com/Azure/bicep-registry-modules.git tmp
git -C tmp checkout -f avm/ptn/authorization/policy-assignment/0.5.3
az bicep build --file tmp/avm/ptn/authorization/policy-assignment/main.bicep
# → 12x Warning BCP318 in main.bicep(191,193,194,198,200,201,205,207,208,212,214,215)
```
Isolation note: reproduced with and without any custom linter config — `BCP318` is a core compiler diagnostic, not a linter rule suppressible via `bicepconfig.json`.
Contributor guide
Research direction
Start with avm/ptn/authorization/policy-assignment/main.bicep, especially the nested output ternary and the lines listed in the issue. Run the provided az bicep build command against version 0.5.3, then verify that the module builds or lints without the 12 BCP318 warnings while preserving the four outputs for each scope.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100