Skip to content

Send task inlets and outlets as JSON lists in OpenLineage facet - #74666

Merged
mobuchowski merged 3 commits into
apache:mainfrom
frank-ye:frankye/o11y-3557-ol-inlets-outlets-json
Oct 19, 2026
Merged

mobuchowski merged 3 commits into
apache:mainfrom
frank-ye:frankye/o11y-3557-ol-inlets-outlets-json

Conversation

@frank-ye

Copy link
Copy Markdown
Contributor

Description

AirflowRunFacet.task now carries two new keys, inlets_list and outlets_list, with the same assets as inlets / outlets but as real JSON lists instead of a Python str(list) repr. Runtime-emitted asset events (from outlet_events) are included, same as in outlets.

Values in extra that JSON can't encode are cast with str() (e.g. Decimal("10") -> "10", a date -> "2026-01-02"), and a str Enum uri is sent as its value. If conversion still fails, a warning is logged and the key is omitted, so the rest of the facet is unaffected.

The existing inlets / outlets string keys are unchanged, so current consumers keep working.

Before / after for one outlet whose extra has a quoted etag and a bool:

"outlets":      "[{'uri': 's3://b/o.csv', 'extra': {'etag': '\"0xABC\"', 'ok': True}, 'type': 'asset'}]"
"outlets_list": [{"uri": "s3://b/o.csv", "extra": {"etag": "\"0xABC\"", "ok": true}, "type": "asset"}]

Motivation

inlets / outlets are sent as a Python repr string, so consumers have to parse Python literal syntax to get the asset uris. Since #65727 added runtime asset events, extra routinely holds free-form user payloads, and values like a string containing " or ', True, None or Decimal(...) make the usual "swap quotes and parse as JSON" approach fail for the whole list. A consumer then silently drops every outlet of the task. Sending a real list removes the need to parse a repr at all.

related: #65727

Testing

  • Unit tests added / updated
    • extra with quotes, apostrophe, True, None -> preserved as-is in outlets_list
    • runtime asset events with Decimal / date in extra -> stringified, alias events keep source_alias
    • task with no inlets / outlets -> empty lists
    • non-encodable value (tuple dict key) -> warning logged, key omitted
  • Serialized an AirflowRunFacet through the OpenLineage client's Serde.to_json and confirmed outlets_list comes out as a JSON array with all values intact

Notes for Reviewer

  • The lists are written onto the dict after InfoJsonEncodable.__init__, because _cast_basic_types turns any list into a repr string. Happy to move this into a generic "raw fields" option on the base class if preferred.
  • Key naming (*_list) is open to suggestions.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Opus 5.5) following the guidelines

@kacpermuda kacpermuda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A solid PR, solving one of the issues OL consumers are facing. It's not introducing any breaking changes, current inlets/outlets keys are untouched, but consumers can get the same information in a properly encoded version by using the _list suffixed keys. Good work !

@kacpermuda

Copy link
Copy Markdown
Collaborator

Can we also please make sure to adjust openlineage system tests files by adding these new keys where they belong? Look at tests/system/openlineage/expected_events and all files that have inlets / outlets specified there.

@frank-ye
frank-ye force-pushed the frankye/o11y-3557-ol-inlets-outlets-json branch from c706677 to e31f175 Compare October 14, 2026 21:27
@frank-ye

Copy link
Copy Markdown
Contributor Author

Can we also please make sure to adjust openlineage system tests files by adding these new keys where they belong? Look at tests/system/openlineage/expected_events and all files that have inlets / outlets specified there.

Good call, added inlets_list / outlets_list to all the expected_events files in e31f175. AF2 ones skip extra since the client drops None values

@mobuchowski
mobuchowski merged commit 6f35805 into apache:main Oct 19, 2026
95 checks passed
@boring-cyborg

boring-cyborg Bot commented Oct 19, 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.

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