This issue was caused by a bug introduced in version 4.16.2 of Astro.
4.16.2
Full bug report and linked pull request with fix is available here: https://github.com/withastro/astro/issues/12210