diff --git a/index-scheduler/src/features.rs b/index-scheduler/src/features.rs index 744b47f11..9eaa658d9 100644 --- a/index-scheduler/src/features.rs +++ b/index-scheduler/src/features.rs @@ -48,8 +48,8 @@ impl RoFeatures { Ok(()) } else { Err(FeatureNotEnabledError { - disabled_action: "Getting logs", - feature: "logsRoute", + disabled_action: "getting logs through the `/logs` route", + feature: "logs route", /// Update the discussion link issue_link: "https://github.com/meilisearch/product/discussions/625", } @@ -95,6 +95,7 @@ impl FeatureData { runtime_features_db.get(&txn, EXPERIMENTAL_FEATURES)?.unwrap_or_default(); let runtime = Arc::new(RwLock::new(RuntimeTogglableFeatures { metrics: instance_features.metrics || persisted_features.metrics, + logs_route: instance_features.logs_route || persisted_features.logs_route, ..persisted_features })); diff --git a/meilisearch-types/src/features.rs b/meilisearch-types/src/features.rs index f7e09317b..04a5d9d6f 100644 --- a/meilisearch-types/src/features.rs +++ b/meilisearch-types/src/features.rs @@ -12,4 +12,5 @@ pub struct RuntimeTogglableFeatures { #[derive(Default, Debug, Clone, Copy)] pub struct InstanceTogglableFeatures { pub metrics: bool, + pub logs_route: bool, } diff --git a/meilisearch/src/option.rs b/meilisearch/src/option.rs index d612210c8..362f7a33f 100644 --- a/meilisearch/src/option.rs +++ b/meilisearch/src/option.rs @@ -538,7 +538,10 @@ impl Opt { } pub(crate) fn to_instance_features(&self) -> InstanceTogglableFeatures { - InstanceTogglableFeatures { metrics: self.experimental_enable_metrics } + InstanceTogglableFeatures { + metrics: self.experimental_enable_metrics, + logs_route: self.experimental_enable_logs_route, + } } } diff --git a/meilisearch/tests/dumps/mod.rs b/meilisearch/tests/dumps/mod.rs index 632180aac..e8061ae4a 100644 --- a/meilisearch/tests/dumps/mod.rs +++ b/meilisearch/tests/dumps/mod.rs @@ -1847,6 +1847,7 @@ async fn import_dump_v6_containing_experimental_features() { { "vectorStore": false, "metrics": false, + "logsRoute": false, "exportPuffinReports": false } "###); diff --git a/meilisearch/tests/features/mod.rs b/meilisearch/tests/features/mod.rs index a8147f111..3a9812f30 100644 --- a/meilisearch/tests/features/mod.rs +++ b/meilisearch/tests/features/mod.rs @@ -20,6 +20,7 @@ async fn experimental_features() { { "vectorStore": false, "metrics": false, + "logsRoute": false, "exportPuffinReports": false } "###); @@ -31,6 +32,7 @@ async fn experimental_features() { { "vectorStore": true, "metrics": false, + "logsRoute": false, "exportPuffinReports": false } "###); @@ -42,6 +44,7 @@ async fn experimental_features() { { "vectorStore": true, "metrics": false, + "logsRoute": false, "exportPuffinReports": false } "###); @@ -54,6 +57,7 @@ async fn experimental_features() { { "vectorStore": true, "metrics": false, + "logsRoute": false, "exportPuffinReports": false } "###); @@ -66,6 +70,7 @@ async fn experimental_features() { { "vectorStore": true, "metrics": false, + "logsRoute": false, "exportPuffinReports": false } "###); @@ -85,6 +90,7 @@ async fn experimental_feature_metrics() { { "vectorStore": false, "metrics": true, + "logsRoute": false, "exportPuffinReports": false } "###); @@ -140,7 +146,7 @@ async fn errors() { meili_snap::snapshot!(code, @"400 Bad Request"); meili_snap::snapshot!(meili_snap::json_string!(response), @r###" { - "message": "Unknown field `NotAFeature`: expected one of `vectorStore`, `metrics`, `exportPuffinReports`", + "message": "Unknown field `NotAFeature`: expected one of `vectorStore`, `metrics`, `logsRoute`, `exportPuffinReports`", "code": "bad_request", "type": "invalid_request", "link": "https://docs.meilisearch.com/errors#bad_request" diff --git a/meilisearch/tests/logs/error.rs b/meilisearch/tests/logs/error.rs index 965b68d17..b6c4605ed 100644 --- a/meilisearch/tests/logs/error.rs +++ b/meilisearch/tests/logs/error.rs @@ -96,3 +96,30 @@ async fn logs_bad_mode() { } "###); } + +#[actix_rt::test] +async fn logs_without_enabling_the_route() { + let server = Server::new().await; + + let (response, code) = server.service.post("/logs", json!({})).await; + snapshot!(code, @"400 Bad Request"); + snapshot!(response, @r###" + { + "message": "getting logs through the `/logs` route requires enabling the `logs route` experimental feature. See https://github.com/meilisearch/product/discussions/625", + "code": "feature_not_enabled", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#feature_not_enabled" + } + "###); + + let (response, code) = server.service.delete("/logs").await; + snapshot!(code, @"400 Bad Request"); + snapshot!(response, @r###" + { + "message": "getting logs through the `/logs` route requires enabling the `logs route` experimental feature. See https://github.com/meilisearch/product/discussions/625", + "code": "feature_not_enabled", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#feature_not_enabled" + } + "###); +} diff --git a/meilisearch/tests/logs/mod.rs b/meilisearch/tests/logs/mod.rs index 4aba0a4cd..ad1fa4048 100644 --- a/meilisearch/tests/logs/mod.rs +++ b/meilisearch/tests/logs/mod.rs @@ -16,8 +16,12 @@ use crate::json; #[actix_web::test] async fn basic_test_log_route() { let db_path = tempfile::tempdir().unwrap(); - let server = - Server::new_with_options(Opt { ..default_settings(db_path.path()) }).await.unwrap(); + let server = Server::new_with_options(Opt { + experimental_enable_logs_route: true, + ..default_settings(db_path.path()) + }) + .await + .unwrap(); let (route_layer, route_layer_handle) = tracing_subscriber::reload::Layer::new(None.with_filter( diff --git a/meilisearch/tests/search/hybrid.rs b/meilisearch/tests/search/hybrid.rs index d3e556ab3..85bc96d86 100644 --- a/meilisearch/tests/search/hybrid.rs +++ b/meilisearch/tests/search/hybrid.rs @@ -15,6 +15,7 @@ async fn index_with_documents<'a>(server: &'a Server, documents: &Value) -> Inde { "vectorStore": true, "metrics": false, + "logsRoute": false, "exportPuffinReports": false } "###);