the following command:
/execute as @a[y=128,dy=128] at @s run fill ~-5 128 ~-5 ~5 128 ~5 black_terracotta
works when executed manually through chat, but cannot be run via command block and shows no errors when trying to do so.
Note that the /fill command on its own runs on the command block without issue, as does a /execute with the same selector. Only together do they fail.
Are you directly above the command block? The origin of search for this command is the X/Z position of the command block – a 1x1 column that extends 128 blocks vertically above Y=128.