Better opts checking for #18538

Addresses #18538.