Skip to content

Commit

Permalink
fix: Add fallbacks when retrieving Airflow configuration to avoid err…
Browse files Browse the repository at this point in the history
…ors being raised (#37994)
  • Loading branch information
kacpermuda authored Mar 8, 2024
1 parent 832d2f5 commit ea5238a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion airflow/providers/openlineage/extractors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def get_operator_classnames(cls) -> list[str]:
@cached_property
def disabled_operators(self) -> set[str]:
return set(
operator.strip() for operator in conf.get("openlineage", "disabled_for_operators").split(";")
operator.strip()
for operator in conf.get("openlineage", "disabled_for_operators", fallback="").split(";")
)

@cached_property
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/openlineage/plugins/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ def get_or_create_openlineage_client(self) -> OpenLineageClient:

def get_openlineage_config(self) -> dict | None:
# First, try to read from YAML file
openlineage_config_path = conf.get("openlineage", "config_path")
openlineage_config_path = conf.get("openlineage", "config_path", fallback="")
if openlineage_config_path:
config = self._read_yaml_config(openlineage_config_path)
if config:
return config.get("transport", None)
# Second, try to get transport config
transport = conf.getjson("openlineage", "transport")
transport = conf.getjson("openlineage", "transport", fallback="")
if not transport:
return None
elif not isinstance(transport, dict):
Expand Down

0 comments on commit ea5238a

Please sign in to comment.