Optional support for static Extra Links without XCom dependency
Description
This feature request entails the addition of an opt-in feature for extra links which are not stored as an XCom, for static URLs and reduced metaDB bloat.
Use case/motivation
As far as I'm aware, extra links are only supported via XComs. This makes sense for dynamic, task-instance specific / DAG-run specific URLs (e.g. a link to an external Spark job); however, XComs are not an ideal mechanism for static URLs which are only specific to the given operator (rather than the task instance). For example, a very common use case for the Extra Links feature is to point to a static, operator-specific documentation page. Yet, storing that URL in an XCom for each task instance is clearly not ideal in that circumstance, and only adds bloat to the metaDB.
Related issues
Only very tangentially related: https://github.com/apache/airflow/issues/54527
Are you willing to submit a PR?
- [x] Yes I am willing to submit a PR!
Caveat: I am willing to help with the backend implementation, but I have no understanding or experience regarding react / frontend development.
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
What is the metaDB? I searched the airflow repo and couldn't find reference to this. Also why aren't XCOM's static, we set variables and retrieve them from downstream tasks (they aren't urls, but they don't change...)?
I'd like to second this request. Right now buttons only show up once a task succeeds. They do not show up while a task is running nor when a task has failed because no xcoms were returned. This really reduces the utility of the buttons compared to AF3
What is the metaDB? I searched the airflow repo and couldn't find reference to this.
Sorry, I believe the official term is the "Metadata Database", but that's a mouthful so I just shorthand it as "metaDB"; however, that isn't an official Airflow term.
Also why aren't XCOM's static, we set variables and retrieve them from downstream tasks (they aren't urls, but they don't change...)?
My concern is not whether XComs are static or not, but rather that using XComs to surface static extra links (i.e. specific extra links which do not change per task instance) is heavy-handed and adds unnecessary load to the database. I mentioned a few examples in this issue description where you might want to refer to the same static URL for a particular operator's extra links.
Okay thanks for the info @zach-overflow ! So for this issue, is the idea to add an optional flag to extra_link.py? If so, I'd like to give it a go.
@zach-overflow, which version of Airflow are you using?
@jroachgolf84 3.2.1
Hi! I implemented this feature and submitted a PR here: https://github.com/apache/airflow/pull/70343
I added a static_url property to BaseOperatorLink that returns None by default. When overridden, get_link() returns it directly — no XCom push needed. All existing subclasses are fully unaffected.
Happy to incorporate any feedback!
Hi! I'd like to work on this.
I've gone through the discussion and PR #70343 (closed by @kaxil). The key lesson: a Task-SDK-only static_url override is not sufficient — the API server deserializes operator links as XComOperatorLink, so a static URL must survive serialization and be resolvable there without an XCom lookup, otherwise the links render empty in the UI.
Plan:
- Add an optional
static_urloverride onBaseOperatorLink(defaults toNone,get_link()falls back to it) - Carry static URLs through the serialization path and make the API-server link resolution return them directly instead of querying XCom
- Unit tests at the SDK, serialization, and API-server resolution layers, plus a docs note for defining extra links
I'll open a PR within 48h. If @iRAFEEK or anyone else is still actively working on this, happy to coordinate.
Two implementation attempts have now landed on the same wall, so before anyone (myself included) spends another round on this, it would help a lot to settle the design direction.
Where the previous attempts ended:
- #70343 (task-SDK-only
static_url) was closed by @kaxil with the key lesson: the API server resolves operator links asXComOperatorLinkreading from XCom, so anything that only lives on the Task-SDK side renders as an empty link in the UI. A static URL must be carried through the serialized DAG. - #76627 (full multi-layer change, incl.
SERIALIZATION_VERSION3 → 4 with a v3→v4 conversion) addressed that, but was withdrawn by its author this week — so the cross-layer questions it raised never got a committer ruling.
The questions I think need an answer before attempt #3:
- Serialization strategy. #76627 bumped
DagSerialization.SERIALIZER_VERSIONto 4, which means bundles written by core ≥ this version will be rejected by cores that only know ≤ 3 (Unsure how to deserialize version 4). Is that trade-off acceptable here, or is there a preference for an additive, non-bumping representation (e.g. encoding static links through the existing link entry shape) that keeps older cores loading new bundles? - Link-class shape. Should
BaseOperatorLinkgrow an optionalstatic_urlwhile keepingget_linkoverridable, with a guard that a concrete subclass must override at least one of them at class-definition time (avoids deferring the error tofinalize(), after the task already ran — @guan404ming's point in #76627)? - When do the buttons render? Today XCom-backed links only show after the task succeeds (which also breaks the use case @NilsJPWerner described — no buttons while running or failed). Static links resolvable from the serialized DAG alone could be returned for any task state. Is that the desired behavior?
- Skip the XCom push. For the metaDB-bloat motivation to actually materialize,
task_runner.pymust skip the XCom push for static links (the fix @aaron-y-chen prompted in #70343). I'd treat that as in-scope rather than follow-up.
If maintainers can confirm a direction on (1) — v4 bump vs non-bumping — I'm happy to take the implementation on (building on the lessons from both prior PRs, credit to @iRAFEEK and the #76627 author for the groundwork).