Skip to content

[Version Pinning] Enforce bicep.version compiler constraint via CompilerVersionValidator  - #20299

Open
Likhitha Kodali (Likhithakmsft) wants to merge 1 commit into
mainfrom
lkodali/bicep_version_pinning_3
Open

[Version Pinning] Enforce bicep.version compiler constraint via CompilerVersionValidator #20299
Likhitha Kodali (Likhithakmsft) wants to merge 1 commit into
mainfrom
lkodali/bicep_version_pinning_3

Conversation

@Likhithakmsft

@Likhithakmsft Likhitha Kodali (Likhithakmsft) commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a runtime check ( CompilerVersionValidator ) that validates the running Bicep CLI version against the  bicep.version  constraint from the effective  bicepconfig.json  for a single file, using the  VersionRange  type.

Emits  BCP456  (error) when the installed version doesn't satisfy the constraint.
Emits  BCP457  (warning) if the running version can't be parsed, so failures are never silent.
Wired into  SemanticModel  diagnostics ,fully backward-compatible.
Covered by unit tests ( CompilerVersionValidatorTests ) and end-to-end compilation tests ( CompilerVersionValidatorEndToEndTests ) in CompilerVersionValidatorTests.cs.

Checklist

Microsoft Reviewers: Open in CodeFlow

@github-actions

Copy link
Copy Markdown
Contributor

Test this change out locally with the following install scripts (Action run 34514897641)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 34514897641
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 34514897641"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 34514897641
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 34514897641"

@Likhithakmsft Likhitha Kodali (Likhithakmsft) changed the title [Version Pinning] Enforce  bicep.version  compiler constraint via  CompilerVersionValidator  [Version Pinning] Enforce bicep.version compiler constraint via CompilerVersionValidator  Sep 10, 2026
Comment on lines +2088 to +2094
public Diagnostic BicepVersionConstraintNotSatisfied(string constraint, string runningVersion) => CoreError(
"BCP456",
$"The installed Bicep CLI version \"{runningVersion}\" does not satisfy the version constraint \"{constraint}\" specified by the \"bicep.version\" configuration property.");

public Diagnostic BicepVersionConstraintCouldNotBeChecked(string constraint, string runningVersion) => CoreWarning(
"BCP457",
$"The installed Bicep CLI version \"{runningVersion}\" could not be parsed, so the \"bicep.version\" constraint \"{constraint}\" could not be checked.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to include the bicepconfig.json file path in the error/warning message?

}

[TestClass]
public class CompilerVersionValidatorEndToEndTests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this to Bicep.Core.IntegrationTests, where we can work with the existing TestEnvironment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants