Skip to content

Commit

Permalink
Extra input validation for multiple executors (apache#39067)
Browse files Browse the repository at this point in the history
Ensure the user provides the module path as the second portion of the
alias:module_path input, not the other way around
  • Loading branch information
o-nikolas authored Apr 17, 2024
1 parent 0667083 commit 1769ed0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions airflow/executors/executor_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ def _get_executor_names(cls) -> list[ExecutorName]:
# complicated. Multiple Executors of the same type will be supported by a future multitenancy
# AIP.
# The module component should always be a module or plugin path.
if not split_name[1] or split_name[1] in CORE_EXECUTOR_NAMES:
module_path = split_name[1]
if not module_path or module_path in CORE_EXECUTOR_NAMES or "." not in module_path:
raise AirflowConfigException(
f"Incorrectly formatted executor configuration: {name}\n"
"second portion of an executor configuration must be a module path"
"Incorrectly formatted executor configuration. Second portion of an executor "
f"configuration must be a module path or plugin but received: {module_path}"
)
else:
executor_names.append(ExecutorName(alias=split_name[0], module_path=split_name[1]))
Expand Down
1 change: 1 addition & 0 deletions tests/executors/test_executor_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def test_get_hybrid_executors_from_config_duplicates_should_fail(self, executor_
"LocalExecutor, CeleryExecutor:, DebugExecutor",
"LocalExecutor, my_cool_alias:",
"LocalExecutor, my_cool_alias:CeleryExecutor",
"LocalExecutor, module.path.first:alias_second",
],
)
def test_get_hybrid_executors_from_config_core_executors_bad_config_format(self, executor_config):
Expand Down

0 comments on commit 1769ed0

Please sign in to comment.