How do i test if there are no blocks above player?

The command should be simple but i can't figure it out basically i want it so that if a player is stanting under a block the command will not activate but if the player has only air blocks above him then the command would activate dealing him some poison damage.


Solution 1:

If you don't want to download a data pack or something, you can just do this:
/execute as <your target> at @s if blocks ~ ~ ~ ~ ~128 ~ ~ ~3 ~ masked run effect give @s minecraft:poison <the time you want> <the strength you want>.