ashb commented on code in PR #55194:
URL: https://github.com/apache/airflow/pull/55194#discussion_r2318354069
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py:
##########
@@ -86,6 +86,22 @@ def get_extra_links(
(link_name, task.get_extra_links(ti, link_name)) for link_name in
task.extra_links
)
all_extra_links = {link_name: link_url or None for link_name, link_url in
sorted(all_extra_link_pairs)}
+ # If no links found, or some are missing, try runtime (_link_*) keys from
XCom
+ if not all_extra_links or any(link is None for link in
all_extra_links.values()):
+ from airflow.models.xcom import XComModel
+
+ query = XComModel.get_many(
+ dag_ids=dag_id,
+ run_id=dag_run_id,
+ task_ids=task_id,
+ map_indexes=map_index,
+ session=session,
+ )
+ for row in query.all():
+ if row.key.startswith("_link_"):
Review Comment:
I'd rather we didn't get everything to then filter this in python space.
```suggestion
for row in query.filter(XComModel.key.like(r"\_link\_"):
```
`\_` is because `_` is the wildcard character for any one character.
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_extra_links.py:
##########
@@ -59,6 +60,16 @@ class AirflowPluginWithOperatorLinks(AirflowPlugin):
]
+class InitExtraLinksOperator(BaseOperator):
+ def __init__(self, value=None, **kwargs):
+ super().__init__(**kwargs)
+ self.value = value
+ self.operator_extra_links = (GoogleLink(),)
Review Comment:
Inside the API tests we need to write the tests to not use the SDK classes,
but to operate on the serialized DAG only.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py:
##########
@@ -86,6 +86,22 @@ def get_extra_links(
(link_name, task.get_extra_links(ti, link_name)) for link_name in
task.extra_links
)
all_extra_links = {link_name: link_url or None for link_name, link_url in
sorted(all_extra_link_pairs)}
+ # If no links found, or some are missing, try runtime (_link_*) keys from
XCom
+ if not all_extra_links or any(link is None for link in
all_extra_links.values()):
Review Comment:
I don't think this will work -- `task.extra` links will be based on the
class attributes, so if a task defines _both_ at the class level and within the
`__init__` level the init-based ones will be missed.
--
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]