Azure / Azure/bicep

Ordering of keys with objectKeys

Open
#14,057 0 comments 0 reactions 0 assignees View on GitHub
intermediate language Needs: Upvote
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**

Bicep CLI version 0.27.1 (4b41cb6d4b)

**Describe the bug**

The `objectKeys` function is described by:

> Returns an array of object keys. Elements are consistently ordered alphabetically.

While this is technically true, it also might be ambiguous in the context of character casing.

**To Reproduce**

Consider:

```bicep
output example3 string[] = objectKeys({ a: 1, b: 2 }) // returns [ 'a', 'b' ]
output example3a string[] = objectKeys({}) // returns []
output example3b string[] = objectKeys({ b: 2, a: 1 }) // returns [ 'a', 'b' ]
output example3c string[] = objectKeys({ A: 2, a: 1 }) // returns [ 'A', 'a' ]
output example3d string[] = objectKeys({ a: 2, A: 1 }) // returns [ 'a', 'A' ]
```

In short `A` and `a` from the example are not sorted.

While unlikely to occur on standard ARM resource properties in isolation. Flagging that this might cause non-deterministic behaviour that is confusing for customers.

Contributor guide

Open the contributing guide

Research direction

Start with the objectKeys documentation and the supplied Bicep examples, then locate the implementation or tests covering object-key ordering. Done when the behavior for keys that differ only by case is deterministic and the documented wording and regression coverage reflect the agreed behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.