Repository: meilisearch/meilisearch
File: crates/meilisearch/src/routes/indexes/settings.rs (Rust)

Code before:
        tokio::task::spawn_blocking(move || index_scheduler.register(task, uid, dry_run))
            .await??
            .into();

    debug!(returns = ?task, "Delete all settings");
    Ok(HttpResponse::Accepted().json(task))
}

fn validate_settings(
    settings: Settings<Unchecked>,
    index_scheduler: &IndexScheduler,
) -> Result<Settings<Unchecked>, ResponseError> {
    use meilisearch_types::milli::update::Setting;
    use meilisearch_types::milli::vector::settings::EmbedderSource;

    let features = index_scheduler.features();
    if let Setting::Set(embedders) = &settings.embedders {
        for SettingEmbeddingSettings { inner: embedder } in embedders.values() {
            let Setting::Set(embedder) = embedder else {
                continue;
            };
            if let Setting::Set(source) = embedder.source {
                if source == EmbedderSource::Composite {
                    features.check_composite_embedders("using `\"composite\"` as source")?;
                }
            }

            if let Setting::Set(_) = &embedder.search_embedder {
                features.check_composite_embedders("setting `searchEmbedder`")?;
            }

            if let Setting::Set(_) = &embedder.indexing_embedder {
                features.check_composite_embedders("setting `indexingEmbedder`")?;
            }
        }
    }

    Ok(settings.validate()?)
}


Review comment (suggestion):
Small style change if you prefer, I’m not especially attached to it, so do whatever you want with it 😁 

```suggestion
            if matches!(embedder.source, Setting::Set(EmbedderSource::Composite)) {
                features.check_composite_embedders("using `\"composite\"` as source")?;
            }
```

Code after:
        tokio::task::spawn_blocking(move || index_scheduler.register(task, uid, dry_run))
            .await??
            .into();

    debug!(returns = ?task, "Delete all settings");
    Ok(HttpResponse::Accepted().json(task))
}

fn validate_settings(
    settings: Settings<Unchecked>,
    index_scheduler: &IndexScheduler,
) -> Result<Settings<Unchecked>, ResponseError> {
    use meilisearch_types::milli::update::Setting;
    use meilisearch_types::milli::vector::settings::EmbedderSource;

    let features = index_scheduler.features();
    if let Setting::Set(embedders) = &settings.embedders {
        for SettingEmbeddingSettings { inner: embedder } in embedders.values() {
            let Setting::Set(embedder) = embedder else {
                continue;
            };
            if matches!(embedder.source, Setting::Set(EmbedderSource::Composite)) {
                features.check_composite_embedders("using `\"composite\"` as source")?;
            }

            if matches!(embedder.search_embedder, Setting::Set(_)) {
                features.check_composite_embedders("setting `searchEmbedder`")?;
            }

            if matches!(embedder.indexing_embedder, Setting::Set(_)) {
                features.check_composite_embedders("setting `indexingEmbedder`")?;
            }
        }
    }

    Ok(settings.validate()?)
}