You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Typically, the following code would apply multiple contracts on a value and if value is a negative number it would fail on the second part of the contract.
-123 | Number | std.number.PosNat
However, this is not the case when applying multiple record contracts and both have the same set of fields. The snippet below should have failed when evaluating container but it doesn't. Based on my testing, this only happens when both inner and outer have the same of fields and adding an additional field to either contracts would give the expected behavior.
let outer = {
spec
| {
hostAliases | Number | optional,
containers | Number | optional,
..
}
| optional,
..
}
in
let inner = {
spec
| {
hostAliases
| optional,
containers
| Array {
..
},
..
}
| optional,
..
}
in
{
spec = {
hostAliases = "this should have failed",
containers = [
{
name = "test",
image = "nginx",
ports = [
{
containerPort = 80,
name = "http"
}
],
}
]
}
} | inner | outer
Expected behavior {} | contract1 | contract2 should work when both contracts run checks against the same set of fields.
Environment
OS name + version: NixOS 24..05
Version of the code: 1.8.0
The text was updated successfully, but these errors were encountered:
Thanks for the report. I can reproduce on 1.8.0, and the optional don't play any role here - the bug still happens if we remove them all. The .. are also not necessary for the repro. The bug was already present in 1.7.0 and 1.6.0. I'll bisect to see when it started, but I think we should make a minor release once it's fixed - silently ignoring contracts is bad.
Given the fact that adding a field to either record fixes the issue, I'm highly suspecting that the contract deduplication optimization isn't sound and consider the two contracts to be equivalent for some reasons, thus eliding the second one.
Describe the bug
Typically, the following code would apply multiple contracts on a value and if value is a negative number it would fail on the second part of the contract.
However, this is not the case when applying multiple record contracts and both have the same set of fields. The snippet below should have failed when evaluating
container
but it doesn't. Based on my testing, this only happens when both inner and outer have the same of fields and adding an additional field to either contracts would give the expected behavior.Expected behavior
{} | contract1 | contract2
should work when both contracts run checks against the same set of fields.Environment
The text was updated successfully, but these errors were encountered: