-
Notifications
You must be signed in to change notification settings - Fork 107
Description
Bug Category
Schemas and Validation
Describe the bug
The translate-schema
CLI command emits the entries in a JSON schema in a nondeterministic order when converting the schema to the cedar
schema format. This is most likely happening because we print entries by iterating over a hashmap/hashset.
Given this schema
{
"": {
"entityTypes": {
"User": {},
"Group": {}
},
"actions": {}
}
}
We sometimes see User
first but other times see Group
first.
jkastner@88665a03aa97 cedar % cargo run -q translate-schema --direction json-to-cedar -s test.cedarschema.json
entity User;
entity Group;
jkastner@88665a03aa97 cedar % cargo run -q translate-schema --direction json-to-cedar -s test.cedarschema.json
entity Group;
entity User;
We should probably sort the entries (i.e., store in a btreemap) and print in that order. More ambitiously, we could try to maintain the order from the JSON, but serde might not make this easy.
This issue applies also to the order of namespaces and actions, not just the order of entity types. I haven't checked, but it might also apply to the order of entries when converting in the other direction.
Expected behavior
.
Reproduction steps
.
Code Snippet
// Put your code below this line.
Log output
// Put your output below this line
Additional configuration
No response
Operating System
No response
Additional information and screenshots
No response