Skip to content

Fix lineage entities sharing mutable defaults across instances - #72509

Merged
mobuchowski merged 1 commit into
apache:mainfrom
keith991001:fix-lineage-entities-mutable-defaults
Sep 9, 2026
Merged

mobuchowski merged 1 commit into
apache:mainfrom
keith991001:fix-lineage-entities-mutable-defaults

Conversation

@keith991001

Copy link
Copy Markdown
Contributor

The attrs entities in airflow.providers.common.compat.lineage.entities declare bare mutable defaults (tags: list[Tag] = [], extra: dict[str, Any] = {}). With @attr.s(auto_attribs=True) such a default is evaluated once and shared class-wide, so mutating one instance silently mutates every other instance:

t1 = Table(database="db", cluster="c", name="t1")
t2 = Table(database="db", cluster="c", name="t2")
t1.tags.append(Tag(tag_name="pii"))
t2.tags  # [Tag(tag_name='pii')] — polluted
t1.tags is t2.tags  # True

This affects Table.tags / columns / owners / extra and Column.tags, i.e. lineage metadata can leak between unrelated entities whenever more than one is constructed. Found while writing the missing test module for this file (#72506).

The fix switches the five defaults to attr.Factory(list) / attr.Factory(dict). Regression tests assert per-instance isolation and fail on the previous code.

Note: #72506 (in flight) adds broader coverage for the same module in the same test file; whichever lands second will be rebased.

related: #35442


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Fable 5)

Generated-by: Claude Code (Fable 5) following the guidelines

Bare mutable defaults on attrs classes are evaluated once and shared
class-wide, so tagging one Table (or Column) silently mutated the
tags/columns/owners/extra of every other instance — corrupting lineage
metadata whenever more than one entity was in play.
@potiuk

potiuk commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

cc: @kacpermuda @mobuchowski ? Do you think there are no side effects (or rather that we get rid of them) ?

@mobuchowski
mobuchowski merged commit a3bf92f into apache:main Sep 9, 2026
112 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 9, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
…e#72509)

Bare mutable defaults on attrs classes are evaluated once and shared
class-wide, so tagging one Table (or Column) silently mutated the
tags/columns/owners/extra of every other instance — corrupting lineage
metadata whenever more than one entity was in play.
xvega pushed a commit to xvega/airflow that referenced this pull request Sep 13, 2026
…e#72509)

Bare mutable defaults on attrs classes are evaluated once and shared
class-wide, so tagging one Table (or Column) silently mutated the
tags/columns/owners/extra of every other instance — corrupting lineage
metadata whenever more than one entity was in play.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants