diff --git a/readthedocs/config/config.py b/readthedocs/config/config.py index bc672e0fd46..2452621e647 100644 --- a/readthedocs/config/config.py +++ b/readthedocs/config/config.py @@ -112,13 +112,20 @@ def catch_validation_error(self, key): try: yield except ConfigValidationError as error: - raise ConfigError( - message_id=error.message_id, - format_values={ + # Expand the format values defined when the exception is risen + # with extra ones we have here + format_values = getattr(error, "format_values", {}) + format_values.update( + { "key": key, "value": error.format_values.get("value"), "source_file": os.path.relpath(self.source_file, self.base_path), - }, + } + ) + + raise ConfigError( + message_id=error.message_id, + format_values=format_values, ) from error def pop(self, name, container, default, raise_ex): diff --git a/readthedocs/config/tests/test_config.py b/readthedocs/config/tests/test_config.py index 021a56b5f7f..c72e2c256b6 100644 --- a/readthedocs/config/tests/test_config.py +++ b/readthedocs/config/tests/test_config.py @@ -424,6 +424,9 @@ def test_new_build_config_invalid_tools_version(self): build.validate() assert excinfo.value.message_id == ConfigValidationError.INVALID_CHOICE assert excinfo.value.format_values.get("key") == "build.tools.python" + assert excinfo.value.format_values.get("choices") == ", ".join( + settings.RTD_DOCKER_BUILD_SETTINGS["tools"]["python"].keys() + ) def test_new_build_config(self): build = get_build_config(