Summary
On some very specific cases, when calling a function that has optional named arguments without providing them will crash the server.
Content Service does not show any error about it.
I did some tests and discovered that on some minimal scenarios it works fine, but on some cases such as this specific example, it freezes the server and crashes.
Please select what you are reporting on:
Verse
What Type of Bug are you experiencing?
Verse
Steps to Reproduce
Copy the following code:
# Returns a map without the map element that Key matches the Key provided
# If Strict is set to true, will force a fail when key does not exist on the map
(Input:[keytype]valuetype where keytype:subtype(comparable), valuetype:type).RemoveByKey<public>(KeyToRemove: keytype, ?Strict:logic=false)<transacts><decides>:[keytype]valuetype = {
if (Strict?). Input[KeyToRemove]
var TempMap:[keytype]valuetype = map{}
for (
CurrentKey->CurrentValue:Input
CurrentKey <> KeyToRemove
). set TempMap[CurrentKey] = CurrentValue
TempMap
}
# Returns a map without all map elements that Key matches the Keys provided
(Input:[keytype]valuetype where keytype:subtype(comparable), valuetype:type).RemoveByKeys<public>(KeysToRemove: []keytype)<transacts><decides>:[keytype]valuetype = {
var TempMap:[keytype]valuetype = Input
for (KeyToRemove : KeysToRemove) {
ResultMap := TempMap.RemoveByKey[KeyToRemove<#, ?Strict := false#>] # Strict default value is already false on the function definition and due to that is not a required argument, but if not mentioned again here, for some reason it crashes the server
set TempMap = ResultMap
}
TempMap
}
2- Try to run the following operations as example:
ABC123Map := map{
"A" => 1
"B" => 2
"C" => 3
}
if (Result := ABC123Map.RemoveByKey["D"]). Print("Try 1 Success!")
else. Print("Try 1 Fail!")
if (Result := ABC123Map.RemoveByKey["D", ?Strict := true]). Print("Try 2 Success!")
else. Print("Try 2 Fail!")
if (Result := ABC123Map.RemoveByKeys["D", "E"]). Print("Try 3 Success!")
else. Print("Try 3 Fail!")
If you want, you can uncomment the <#, ?Strict := false#>
part of the code and run the test again. Doing that, you will see that the code will properly work without any crashes.
Expected Result
Server does not freeze/crashes and prints:
-Try 1 Success!
-Try 2 Fail!
-Try 3 Success!
Observed Result
Server freeze/crashes and only prints:
-Try 1 Success!
-Try 2 Fail!
//crashes here
Platform(s)
Windows / Verse VM / Server
Additional Notes
-RemoveByKey[]
works properly, but as soon as we use it inside the other function, that line crashes when the code is executed
-On minimal scenarios when trying to reproduce the bug with simpler barebone functions, the problem did not existed
-Testing with different parameter and map values still causes the problem