khoaanguyenn opened a new issue, #65354: URL: https://github.com/apache/airflow/issues/65354
### Description The `ExtraLinks` component in the task instance detail view does not forward the currently selected `try_number` to the extra links API endpoint. As a result, `BaseOperatorLink.get_link` always receives a `ti_key` with the latest attempt's `try_number`, making it impossible to return attempt-specific URLs. The Details page already tracks the selected attempt via `SearchParamsKeys.TRY_NUMBER` and uses it to fetch per-attempt data via `useTaskInstanceServiceGetTaskInstanceTryDetails`. However, [`ExtraLinks`](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/ui/src/pages/TaskInstance/Details.tsx#L98) does not receive or forward this value. **Call chain today:** 1. UI calls `GET /dags/{dag_id}/dagRuns/{run_id}/taskInstances/{task_id}/links` — no `try_number` param 2. [Endpoint fetches `TaskInstance` row](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py#L63-L70) (always reflects latest attempt) 3. Calls [`task.get_extra_links(ti, link_name)`](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py#L78-L79) → [`link.get_link(self, ti_key=ti.key)`](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/serialization/definitions/baseoperator.py#L287) 4. [`ti.key`](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/models/taskinstance.py#L895-L897) builds `TaskInstanceKey(..., self.try_number, ...)` — always the latest ### Use case/motivation A custom `BaseOperatorLink` plugin that links to an external log viewer filtered by worker hostname and execution time window. When a task retries across different workers, each attempt runs on a different host. The link should point to the correct host's logs for the attempt the user is viewing — not always the latest attempt. The plugin can query `TaskInstanceHistory` using `ti_key.try_number` to resolve per-attempt metadata, but only if `try_number` correctly reflects the viewed attempt. **Suggested change:** 1. Add optional `try_number` query parameter to the [extra links endpoint](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/api_fastapi/core_api/routes/public/extra_links.py#L43-L50) 2. Pass `tryNumber` from [`Details.tsx`](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/ui/src/pages/TaskInstance/Details.tsx#L69) to [`ExtraLinks`](https://github.com/apache/airflow/blob/3.2.0/airflow-core/src/airflow/ui/src/pages/TaskInstance/ExtraLinks.tsx), which forwards it to the API call 3. In the endpoint, when `try_number` is provided, use [`ti.key.with_try_number(try_number)`](https://github.com/apache/airflow/blob/3.2.0/task-sdk/src/airflow/sdk/types.py#L76) so `get_link` receives the viewed attempt's `try_number` No changes to `BaseOperatorLink.get_link` signature needed — [`TaskInstanceKey`](https://github.com/apache/airflow/blob/3.2.0/task-sdk/src/airflow/sdk/types.py#L62-L69) already has `try_number`. ### Related issues None found. ### Are you willing to submit a PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md) **Airflow version:** 3.2.0 -- 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]
