dheerajturaga commented on code in PR #74278:
URL: https://github.com/apache/airflow/pull/74278#discussion_r4190006667
##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/plugins.py:
##########
@@ -69,16 +69,19 @@ class AppBuilderMenuItemResponse(BaseModel):
category: str | None = None
-class PluginAppliesToResponse(BaseModel):
- """Serializer for the optional Dag/task scoping criteria of a UI plugin."""
+class PluginAppliesToResponse(RootModel[dict[str, list[str]]]):
+ """
+ Serializer for the optional scoping criteria of a UI plugin.
- model_config = ConfigDict(extra="forbid")
+ An open map of dotted field path to the values that path may take -- not a
closed set of
+ criteria. ``{"state": ["failed"], "dag.tags.name": ["ml"]}`` scopes to
failed entities of
+ ml-tagged Dags. An unqualified path is rooted at the entity the
``destination`` is about;
+ a path may instead name a related record (``dag``, ``dag_run``, ``task``,
``task_instance``)
+ as its first segment. Matching is equality against the listed values, OR
within a path and
+ AND across paths, and is evaluated client-side.
+ """
- dag_tags: list[str] | None = None
- dag_ids: list[str] | None = None
- task_ids: list[str] | None = None
- operators: list[str] | None = None
- operator_names: list[str] | None = None
+ root: dict[str, list[str]] = Field(default_factory=dict)
Review Comment:
Could we align null handling with `_describe_applies_to_error()`? That
validator accepts `None`, but this response model rejects it. I reproduced a
case where `applies_to={"state": None}` passes plugin validation and then
causes the entire plugin, including its other valid views, to be omitted from
the plugins API response. Normalizing null values away, or rejecting them
during plugin validation so the existing unscoped fallback runs, would keep the
behavior consistent.
---
Drafted-by: Codex (GPT-6); reviewed by @dheerajturaga before posting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]