How can I use the same function call to sample from posterior when data exists and only sample from prior when not?

I have a brms model where sometimes there is no data, in which case I want brms to sample from the prior just as it normally would the posterior.

Previously, I had code like this:

cond <- ...

if (sum(cond) == 0) {
  samplePrior <- "only"
  cond <- TRUE
} else {
  samplePrior <- "no"
}

model <- brm(
  y ~ . + 0,
  data = X[cond, ],
  samplePrior = samplePrior,
  backend = "cmdstanr",
  ...
)

This worked as of one year ago, or maybe two years. Now, I get:

Error in validate_data():
! All observations in the data were removed presumably because of NA values.
Run rlang::last_trace() to see where the error occurred.
Warning message:
Rows containing NAs were excluded from the model.

How can I dynamically sample from just the prior when I have no data to pass to the model?