Skip to content

Commit 58aeb64

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 58aeb64

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,22 @@ 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+
@hooks.Actions.CONFIG_LOADED.add()
363+
def _check_run_meilisearch(config: Config) -> None:
364+
"""
365+
In case RUN_MEILISEARCH is set to false, check if
366+
MEILISEARCH_URL has been set to a non-default value.
367+
If not, print a warning to notify the user.
368+
"""
369+
370+
run_meilisearch = get_typed(config, "RUN_MEILISEARCH", bool, True)
371+
if not run_meilisearch:
372+
meilisearch_url = get_typed(config, "MEILISEARCH_URL", str, "")
373+
meilisearch_url_default = get_defaults()['MEILISEARCH_URL']
374+
if meilisearch_url == meilisearch_url_default:
375+
fmt.echo_alert(
376+
"Warning: RUN_MEILISEARCH is false, but MEILISEARCH_URL is unset. "
377+
"This configuration is not typically recommended and may lead to unexpected behavior. "
378+
"Consider setting RUN_MEILISEARCH, or setting MEILISEARCH_URL to an existing, preconfigured Meilisearch instance."
379+
)

0 commit comments

Comments
 (0)