den icon indicating copy to clipboard operation
den copied to clipboard

BUG: Unexpected result for `host.hasAspect`

Open tschan opened this issue 5 months ago • 11 comments

Description

host.hasAspect in the conditional of a policy.when call returns true for a host that does not include the aspect if a host that gets evaluated before has included said aspect.

Tests can be found here: https://github.com/tschan/den-hasaspect-bug

The first test has a host that includes the aspect before the host that checks with hasAspect (this one fails) while the second test switches this order around (this one passes).

tschan avatar Jun 13 '26 22:06 tschan

Can you verify if this still occurs against the soon to be merged #563?

sini avatar Jun 13 '26 22:06 sini

Still fails against https://github.com/sini/den/commit/a7e86b97e99cee7f8be29eb2e67e30d8b6e8737d

tschan avatar Jun 13 '26 22:06 tschan

Thanks, I'll land a fix with #563 -- it's in the code path it touches so doesn't adjust the scope. :)

sini avatar Jun 13 '26 22:06 sini

Found the root cause; it wasn't correctly constraining scope allowing for cross-host pollution. Sorry about that -- that's a decidedly nasty regression. It's fixed on #563 now.

sini avatar Jun 13 '26 23:06 sini

Awesome, thank you for fixing the problem so quickly.

With this I also realized a change in behaviour that I'm not sure is intentional or not. To be clear: This change was not introduced in your commit fixing the original issue but exists when comparing current main and your feature branch.

This is the test running on current main. It passes: https://github.com/tschan/den-hasaspect-bug/blob/a55a3590325f575293cc0cf19e139a086c731da8/modules/bug.nix

Now changing to your feature branch makes the exact same test fail: https://github.com/tschan/den-hasaspect-bug/blob/c37b675b731a5a28620ee02bc66243c42862d812/modules/bug.nix

tschan avatar Jun 14 '26 10:06 tschan

That's what I get for running parallel development branches. 🤦 I'll make sure #602 gets properly honored in #563 and expand test coverage for it.

sini avatar Jun 14 '26 18:06 sini

@tschan #563 should now be fixed; thanks for the report -- I'm working on a test coverage matrix now. :)

sini avatar Jun 14 '26 18:06 sini

This is also fixed now, perfect!

Unfortunately I have found another problem which I think is related to the first case, but instead of evaluation order dependent behaviour with includes it happens with excludes. 🙈

You can find a test case here: https://github.com/tschan/den-hasaspect-bug/blob/d6e0f8891ce7f2f1ffb8528077cd87952217d0f7/modules/bug.nix

tschan avatar Jun 14 '26 20:06 tschan

Doing a larger refactor on 563 that will increase the scope change but ensure a single logic path. I might not be done until tomorrow though. Will update here after it lands and I'll review and add your test to deadbugs.

sini avatar Jun 15 '26 00:06 sini

I tried with the newest version of your feature branch and everything seems to be working as expected now. Thank you for your quick fixes! 🙂

tschan avatar Jun 15 '26 11:06 tschan

This is now resolved. Feel free to open an issue for any new observed regressions, the current HEAD of main (baring any major bug discoverys) will serve as the parity target for the next engine rewrite.

sini avatar Jun 15 '26 17:06 sini