Since porkbun returns an 400 error, I might guess something is wrong with the API call we do. Sadly https://porkbun.com/api/json/v3/documentation is not very detailed here, nor is the error message itself.
Possibly the API requires something else for the naked domain, since the subdomains work apparently fine then. But also I can't find anything mentioned in the docs 😕
Can you check if this might be a record conflict error which just reports as 400? Like do A records for that already exist?