Skip to content

Comments

Add default value syntax for variable replacement#51

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/add-variable-default-value-option
Draft

Add default value syntax for variable replacement#51
Copilot wants to merge 5 commits intomainfrom
copilot/add-variable-default-value-option

Conversation

Copy link

Copilot AI commented Feb 19, 2026

Variable replacement currently substitutes empty strings when parameters are missing. This adds optional default value syntax: %%VARIABLENAME:DefaultValue%%.

Changes

Core implementation (Convert-SentinelARYamlToArm.ps1)

  • Extended variable replacement regex to match %%VAR:default%% pattern in addition to %%VAR%%
  • Applied negative lookahead (?!%%) to correctly parse default values containing % characters
  • Replacement order: parameter values → default values → empty string

Syntax rules

  • Variable names cannot contain : or % (prevents ambiguity)
  • Default values can contain % (but not %% sequence)
  • Parameters always override defaults

Example behavior

-- Input query
| where ErrorCount > %%Threshold:100%%
| where Code in (%%Codes:500%%)
| where Message contains "%%Filter%%"

-- With parameters: { Threshold: 50, Codes: [403, 404] }
| where ErrorCount > 50
| where Code in ("403","404")
| where Message contains ""

-- Without parameters
| where ErrorCount > 100
| where Code in (500)
| where Message contains ""

Testing

  • Added test fixtures with mixed variable scenarios
  • Tests cover: defaults only, parameters only, mixed, edge cases

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.powershellgallery.com
    • Triggering command: /usr/bin/pwsh pwsh -Command Set-PSRepository PSGallery -InstallationPolicy Trusted; Install-Module powershell-yaml, PSScriptAnalyzer, Pester -Force -Scope CurrentUser (dns block)
    • Triggering command: /usr/bin/pwsh pwsh -Command Install-Module powershell-yaml, PSScriptAnalyzer, Pester -Force -Scope CurrentUser -SkipPublisherCheck /home/REDACTED/work/SentinelARConverter/SentinelARConverter (dns block)
    • Triggering command: /usr/bin/pwsh pwsh -Command Register-PSRepository -Default -ErrorAction SilentlyContinue; Install-Module powershell-yaml, PSScriptAnalyzer, Pester -Force -Scope CurrentUser -SkipPublisherCheck (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add option for variable default value</issue_title>
<issue_description>### Summary of the new feature / enhancement

When converted and no variable is provided a default fallback should be available

Proposed technical implementation details (optional)

Currently %%VARIABLENAME%% is replaced with the variable but with nothing if not available
A solution would be to have %%VARIABLENAME:DefaultValue%% as a optional text

%%VARIABLENAME%%` -> VARIABLENAME = "TEST" = "TEST"
%%VARIABLENAME%%` -> VARIABLENAME = null = ""
%%VARIABLENAME:10%%` -> VARIABLENAME = "20" = "20"
%%VARIABLENAME:10%%` -> VARIABLENAME = null = "10"
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 19, 2026 10:02
Co-authored-by: f-bader <3834359+f-bader@users.noreply.github.com>
Co-authored-by: f-bader <3834359+f-bader@users.noreply.github.com>
Co-authored-by: f-bader <3834359+f-bader@users.noreply.github.com>
Co-authored-by: f-bader <3834359+f-bader@users.noreply.github.com>
Copilot AI changed the title [WIP] Add option for variable default value Add default value syntax for variable replacement Feb 19, 2026
Copilot AI requested a review from f-bader February 19, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option for variable default value

2 participants