Fix/replacequeryvariables quoting#54
Open
andrewj-t wants to merge 2 commits into
Open
Conversation
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>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.