Skip to content

Fix/replacequeryvariables quoting#54

Open
andrewj-t wants to merge 2 commits into
f-bader:mainfrom
andrewj-t:fix/replacequeryvariables-quoting
Open

Fix/replacequeryvariables quoting#54
andrewj-t wants to merge 2 commits into
f-bader:mainfrom
andrewj-t:fix/replacequeryvariables-quoting

Conversation

@andrewj-t
Copy link
Copy Markdown

Fixes #53

Switches the count-based discriminator (Count -gt 1) to a YAML-list type check, with per-element pass-through for values already wrapped in matching " or '. Existing rules using the embedded-quote workaround keep working unchanged.

andrewj-t and others added 2 commits May 9, 2026 20:23
Single-element YAML lists in the parameters file (e.g. `key: [admin]`)
were emitted as unquoted barewords because the discriminator used
`.Count -gt 1` instead of "is this a list?". This produced invalid KQL
inside `in (%%X%%)` and `dynamic([%%X%%])` patterns.

Switch to `-is [System.Collections.IList] -and -isnot [string]`, which
matches the `Generic.List[Object]` type powershell-yaml returns for
YAML sequences. Scalars stay raw, so the documented
`> %%NumberOfErrors%%` -> `> 200` behaviour is preserved.

Per-element handling also passes through values already wrapped in
matching " or ' quotes, so existing rules using the embedded-quote
workaround (e.g. `- '"admin@x.com"'`) keep producing valid KQL without
edits, and now also work at multi-element scale.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nd compat

New fixture pair (ScheduledReplaceQueryVariables.yaml + .params.yaml)
and one Context block covering list/scalar substitution and the
embedded-quote workaround used by pre-fix rules:

- single-element numeric list `[403]` -> `("403")`
- single-element string list with apostrophe (`Timothy O'Toole`) -> quoted, preserved
- multi-element string list with apostrophes -> all quoted, joined
- empty list `[]` -> single empty quoted string `("")`
- scalar number -> emitted raw
- scalar string with apostrophe (`Mary O'Brien's account`) -> raw, KQL-safe
- defaults fall through when variable is not in parameter file
- single-element double-quote workaround (`- '"403"'`) -> `("403")`
- single-element single-quote workaround (`- "'403'"`) -> `('403')`
- multi-element mix of pre-quoted and bare elements is handled per-element

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

ReplaceQueryVariables: single-element arrays emitted as unquoted barewords

1 participant