Azure / Azure/azure-dev

deploymentStacks: reject partially-unresolved ${VAR} in deny-list entries

Open
#9,357 0 comments 0 reactions 0 assignees View on GitHub
area/bicep bug
Dominant language
Go
Stars
569
Forks
364
Avg merge
2d 19h
Merged PRs (30d)
136

Description

## Context

Follow-up from PR #9238 (`${VAR}` substitution in `infra.deploymentStacks`).

`resolveDeploymentStacksValues` (`cli/azd/pkg/infra/provisioning/bicep/deployment_stacks.go`) currently rejects an entry only when the **entire** expanded value trims to empty. Composite entries with an unset variable slip through:

```
Microsoft.Authorization/${UNSET_SCOPE}/write -> Microsoft.Authorization//write (sent to ARM)
```

`excludedPrincipals` is usually a bare `${VAR}` (so a full-blank result is caught), but `excludedActions` entries are commonly composite and more likely to hit this.

## Constraint

The fix cannot simply key off `len(lookedUpEmpty) > 0`: the `Envsubst` callback records the variable name for `${VAR:-fallback}` **before** the default is applied, so a naive check would reject valid defaulted values and break `TestResolveDeploymentStacksMap_DefaultExpression`.

## Proposed fix

Detect a variable reference that was genuinely unset **and** not satisfied by a default (e.g. compare the pre/post-expansion for that specific reference, or evaluate each reference individually), and error out with the offending variable name. Keep `${VAR:-default}` working. Add a regression test for a composite `excludedActions` entry with an unset variable.

## Scope / priority

Alpha feature (`AZD_ALPHA_ENABLE_DEPLOYMENT_STACKS`); limited blast radius. Non-blocking; raised by @jongio and @richardpark-msft on PR #9238.

Contributor guide

Open the contributing guide

Research direction

Start in cli/azd/pkg/infra/provisioning/bicep/deployment_stacks.go at resolveDeploymentStacksValues, then inspect TestResolveDeploymentStacksMap_DefaultExpression to understand default handling. Add a regression test for a composite excludedActions entry with an unset variable; done means it errors with the variable name while ${VAR:-default} remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, go
Domain
cli, cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.