Skip to content

Commit 768c893

Browse files
committed
feat: Add a plausibility check for Meilisearch configuration
Tutor is meant to be configured with either its own, or an externally preconfigured Meilisearch instance. Thus, the combination of configuring RUN_MEILISEARCH: false and leaving MEILISEARCH_URL at its default is almost certainly a configuration error. Add an alert to notify the user of that configuration issue. Related issue: #1185
1 parent 2b36492 commit 768c893

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Improvement] Add a plausibility check that issues a warning if `RUN_MEILISEARCH` is `false` but `MEILISEARCH_URL` is unset. (by @fghaas)

tutor/config.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,23 @@ def _check_preview_lms_host(config: Config) -> None:
358358
f'Warning: PREVIEW_LMS_HOST="{preview_lms_host}" is not a subdomain of LMS_HOST="{lms_host}". '
359359
"This configuration is not typically recommended and may lead to unexpected behavior."
360360
)
361+
362+
363+
@hooks.Actions.CONFIG_LOADED.add()
364+
def _check_run_meilisearch(config: Config) -> None:
365+
"""
366+
In case RUN_MEILISEARCH is set to false, check if
367+
MEILISEARCH_URL has been set to a non-default value.
368+
If not, print a warning to notify the user.
369+
"""
370+
371+
run_meilisearch = get_typed(config, "RUN_MEILISEARCH", bool, True)
372+
if not run_meilisearch:
373+
meilisearch_url = get_typed(config, "MEILISEARCH_URL", str, "")
374+
meilisearch_url_default = get_defaults()["MEILISEARCH_URL"]
375+
if meilisearch_url == meilisearch_url_default:
376+
fmt.echo_alert(
377+
"Warning: RUN_MEILISEARCH is false, but MEILISEARCH_URL is unset. "
378+
"This configuration is not typically recommended and may lead to unexpected behavior. "
379+
"Consider setting RUN_MEILISEARCH, or setting MEILISEARCH_URL to an existing, preconfigured Meilisearch instance."
380+
)

0 commit comments

Comments
 (0)