Repository navigation
Fix handling of quoted digit path segments in Azure Policy - #866
Merged
Anand Krishnamoorthi (anakrish) merged 4 commits intoOct 27, 2026
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Quoted digit subscripts are object keys in field conditions, field(), wildcard prefixes and suffixes, and count collections. Pin the array counterexample: a quoted digit no longer indexes an array. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An empty quoted subscript (a[''], a[""]) is now reported as "empty quoted key in path" instead of sharing the "empty bracket" message used for a[]. Pin both errors with a unit test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Anand Krishnamoorthi (anakrish)
approved these changes
Oct 27, 2026
Anand Krishnamoorthi (anakrish)
merged commit Oct 27, 2026
c61a08e
into
microsoft:main
60 checks passed
This was referenced Oct 27, 2026
Closed
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.
Summary
In Azure Policy, the compiler now keeps quoted digit subscripts as object keys and preserves quote characters inside a quoted key.
Before:
split_path_without_wildcardsreturned plain strings, and the code that builds the lookup turned any segment that parsed as au64into an array index. A source comment already flagged this as a TODO. As a result:tags['123']looked up index 123 on the tags object, returning Undefined instead of the tag named123.properties.m.0indexed instead of reading key0.trim_matchesremoved every quote character from both ends, soconfig["'123'"]lost the apostrophes that are part of the key name'123'.After: the splitter returns typed segments,
PathSegment::{Key, Index(u64)}. The key/index decision is made from the source syntax, where the information still exists:ipRules[0], is anIndex.Key. An empty quoted key is an error.The typed segments are used everywhere a path is compiled: field conditions,
field(), wildcard prefixes and suffixes, and count collections.Behavior changes
tags['123']andtags["123"]now read the tag named123.arr['0']) no longer indexes, so it is Undefined.arr.0) no longer indexes, so it is Undefined on an array and reads key0on an object.Tests
14 new YAML cases in
fields.yamlandcount.yaml, covering field conditions,field(), wildcard prefixes and suffixes, and count collections. Each has a non-match twin where relevant. There are also unit tests incompiler/utils.rs. Run againstmain's source,field_tags_numeric_key_bracketandfield_count_quoted_numeric_key_collectionfail: the expectedauditcomes back Undefined.field_array_numeric_index_still_indexesconfirms thatipRules[0]-style indexing still works.