Add simple extra links support for TaskFlow tasks#69426
Open
fredthomsen wants to merge 1 commit into
Open
Conversation
Enable @task(extra_links=["Name", ...]) so decorated tasks can set link URLs at runtime via the extra_links context variable (extra_links["Name"] = "https://..."). Links are pre-declared in the decorator for two reasons: 1. Keep webserver link rendering consistent with how provider-based operator links already work 2. Warn when a task overrides links from other sources URLs are pushed to XCom via SUPERVISOR_COMMS on every assignment, so links work even when the task runs in a subprocess (e.g. @task.virtualenv).
aaa36f0 to
90df9fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, adding extra links to a TaskFlow task required creating
a custom BaseOperator subclass with operator_extra_links and a
companion BaseOperatorLink class. This is heavyweight for what is
often just a URL set at runtime.
This change lets @task authors declare link names in the decorator
and set URLs directly during execution:
What's included:
TaskFlowExtraLink— a concreteBaseOperatorLinkthat storesURLs via in-memory, created at parse time from declared link names
_build_extra_links()merges TaskFlow links with existingclass-level links, warning on name conflicts
ExtraLinksAccessor— dict-like context object injected ascontext["extra_links"]for setting URLs during executionunmap()operator_extra_linksmachinery (no new XCom keys or API changes needed)
closes: #54527
Simple DAGs used to verify this solution:
A previous attempt (#55257) stalled because it bypassed the existing
operator_extra_linksserialization pipeline: it pushed a plaindictinfinalize()and patched the webserver API with XCom wildcard scans, whichraised concerns about key collisions and split data sources.
This PR sidesteps those issues by creating
TaskFlowExtraLinkobjects atparse time via
@task(extra_links=["Name"]), plugging directly into theexisting
operator_extra_links→ serialization →XComOperatorLinkpipeline so no webserver changes are needed. URLs are pushed immediately via
SUPERVISOR_COMMS, so@task.virtualenvworks transparently. The tradeoffis that link names must be pre-declared in the decorator rather than created
dynamically at runtime.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.Important
🛠️ Maintainer triage note for @fredthomsen · by
@potiuk· 2026-07-08 15:38 UTCHelpful heads-up from the maintainers — please address before this PR can be reviewed:
Integration and System Tests / Integration: providers elasticsearch). See the contributor guide.Full criteria: Pull Request quality criteria.
The ball is in your court — you've been assigned to this PR. Fix the above, then mark it Ready for review.
Automated triage — may be imperfect; a maintainer takes the next look.