The documentation for that grid function lists the inputs as:
One or more param objects (such as mtry() or penalty() ). None of the objects can have unknown() values in the parameter ranges or values.
In your example, you are tuning over mtry. This depends on the number of columns in your data set so there is no known upper limit:
> mtry()
# Randomly Selected Predictors (quantitative)
Range: [1, ?]
The error message points to finalize() and there are examples in that help topic.
There is a lot more about this stuff in Tidy Models with R.
Let's say that you were modeling the mtcars data set:
library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#> method from
#> required_pkgs.model_spec parsnip
model <-
rand_forest(mode = "regression",
mtry = tune(),
trees = tune()) %>%
set_engine(engine = "ranger")
# Get rid of the unknown
rf_param <-
model %>%
parameters()
# mtry still needs to be finalized:
rf_param
#> Collection of 2 parameters for tuning
#>
#> identifier type object
#> mtry mtry nparam[?]
#> trees trees nparam[+]
#>
#> Model parameters needing finalization:
#> # Randomly Selected Predictors ('mtry')
#>
#> See `?dials::finalize` or `?dials::update.parameters` for more information.
rf_param <-
rf_param %>%
# Give it the predictors to finalize mtry
finalize(x = mtcars %>% select(-mpg))
rf_param
#> Collection of 2 parameters for tuning
#>
#> identifier type object
#> mtry mtry nparam[+]
#> trees trees nparam[+]
rf_param %>%
grid_latin_hypercube(size = 3)
#> # A tibble: 3 x 2
#> mtry trees
#> <int> <int>
#> 1 10 167
#> 2 2 1565
#> 3 6 1159
Created on 2021-07-01 by the reprex package (v2.0.0)