Skip to content

Conversation

@Owen-CH-Leung
Copy link
Contributor

@Owen-CH-Leung Owen-CH-Leung commented Jul 19, 2025

closes: #53527

Airflow 3 introduces several mandatory variable for api-server. One of them is show_external_log_redirect in the ConfigResponse class

This class will be validated by pydantic and if the validation fails, it returns runtime error as described in the issue

pydantic_core._pydantic_core.ValidationError: 1 validation error for ConfigResponse
show_external_log_redirect
  Input should be a valid boolean [type=bool_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.11/v/bool_type

Such validation will take place when api-server is up and running and a http request is sent to the endpoint /config.

@config_router.get(
"/config",
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]),
dependencies=[Depends(requires_authenticated())],
)
def get_configs() -> ConfigResponse:

Inside this handler function, an instance of TaskLogReader is created, and show_external_log_redirect will take the attribute value of supports_external_link in the task log reader

Class TaskLogReader does have thie property supports_external_link, which will delegate it to the log handler's supports_external_link

@property
def supports_external_link(self) -> bool:
"""Check if the logging handler supports external links (e.g. to Elasticsearch, Stackdriver, etc)."""
if not isinstance(self.log_handler, ExternalLoggingMixin):
return False
return self.log_handler.supports_external_link

But OpensearchTaskHandler does not impl this property. Hence None is sent to pydantic for validation and hence the error.

@kyungjunleeme
Copy link
Contributor

kyungjunleeme commented Jul 19, 2025

First, I saw the pr. Good.
Do we dont need to add test code about pr.?

@Owen-CH-Leung
Copy link
Contributor Author

The bug only shows up when Airflow is started with OpenSearchTaskHandler and the /config endpoint is queried.
That makes it an integration‑level concern, not a pure unit‑test case.

From what I read, Airflow core purposely doesn’t want to import specific provider code (other than the common code obviously) at test time; the handler is pulled in dynamically at runtime based on config. The failure path involves the full request stack (TaskLogReader → ConfigResponse) plus the provider package. A unit test that stubs settings.remote_log_handler won’t tell us whether the real handler can be instantiated, its dependencies load, and the JSON flag is set end‑to‑end.

Speaking more broadly - I think there's an integration test gap here. I couldn’t find any existing integration test that boots Airflow with each remote‑log provider and hits /config. Providers do have isolated unit tests, but nothing that covers the cross‑boundary behaviour we’re touching here

@eladkal eladkal requested a review from ashb July 19, 2025 15:06
@potiuk
Copy link
Member

potiuk commented Jul 19, 2025

Speaking more broadly - I think there's an integration test gap here. I couldn’t find any existing integration test that boots Airflow with each remote‑log provider and hits /config. Providers do have isolated unit tests, but nothing that covers the cross‑boundary behaviour we’re touching here

Actually this is because of lack of ABCMeta meta-class in definition of ExternalLoggingMixin. All the "External" handlers derive from it and since ExternalLoggingMixin does not have ABCMeta as Metaclass, so you can instantiate the derived classes even if the methods are declared as abstract methods:

Screenshot 2025-07-19 at 20 13 04

@Owen-CH-Leung -> Maybe you can fix it as part of that PR (that would be equivalent of tests). What should happen when you add the metaclass, regular unit tests should fail for all the log handlers that have missing abstract methods because it will be impossible to instantiate them.

@Owen-CH-Leung
Copy link
Contributor Author

Thanks. I've set ExternalLoggingMixin to have metaclass metaclass=abc.ABCMeta. The OpensearchTaskhandler then errors out when instantiating and I've added the required methods to make it pass

@eladkal eladkal requested a review from potiuk July 21, 2025 13:03
@potiuk
Copy link
Member

potiuk commented Jul 21, 2025

Thanks. I've set ExternalLoggingMixin to have metaclass metaclass=abc.ABCMeta. The OpensearchTaskhandler then errors out when instantiating and I've added the required methods to make it pass

Yep. As expected :)

@potiuk potiuk merged commit f80a445 into apache:main Jul 21, 2025
72 checks passed
@potiuk
Copy link
Member

potiuk commented Jul 21, 2025

Just thinking... if there will be other providers that will fail after that one (I just realized it only run a subset of provider tests) - if the main will be failing we will have to make a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpensearchTaskHandler is failing to start at main

5 participants