Assuming no misconfigured resource packs are present, in-game actions like these really shouldn’t be producing errors. The fact that this appears probably isn’t a good thing.
Perhaps invalid stack sizes should be set to 1 (if they aren’t already) rather than trying to specifically go out of your way to try and render a stack with an invalid quantity value?
Thank you for helping us improve Minecraft! We saved your files: