Deploy previews failing but branch deploys succeeding

We’re getting this build error on deploy previews (triggered by Bitbucket PRs), but then when we merge the PR and it triggers a branch deploy it succeeds without any issues.

Last failed deploy preview:

The next build which was triggered by merging that PR and succeeded:

Deploy preview build error:

Any ideas?

We had the same problem with preview deploys, so we finally added default values and validations across all the site to fix this.

Hiya, are you still experiencing this issue?

I ended up removing the page query that was problematic. We were filtering WordPress posts by slug to get the /search slug and use that for title and other dynamic UI labelling, but for some reason it never worked with deploy preview builds. So we just ripped it out and we’re hard coding that stuff for now. Still remains a head scratcher.