Skip to content

Unified link converters - #1885

Open
Evanthx wants to merge 3 commits into
mainfrom
link_converter
Open

Evanthx wants to merge 3 commits into
mainfrom
link_converter

Conversation

@Evanthx

@Evanthx Evanthx commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What was changed

Unified the Link Converter code - modelling what was done for Java and bringing into the other SDKs:
temporalio/sdk-java#3068

There are multiple encoding and decoding methods for links, all pretty close but not quite. That had me worried as it is easy for them to get out of sync. This PR should be no functional changes, but merges those methods.

I also compared the behavior across the other SDKs, and am unifying them - a few edge cases didn't quite match up. Testing was added around these edge cases.

Changes in Python SDK behavior are:

  1. eventID is omitted when the event ID is 0. Zero is not a valid event ID, and the other SDKs omit the parameter; the event type alone identifies the event in that case.
  2. The URL scheme is validated. This SDK matched on url.path only and never read url.scheme, so it accepted https:///nl link. Every other SDK checks.

@Evanthx
Evanthx requested a review from a team as a code owner September 18, 2026 22:29
Comment thread CHANGELOG.md Outdated
@Evanthx Evanthx added the skip-changelog PR changes do not require changelog updates label Sep 29, 2026
@Evanthx
Evanthx requested a review from tconley1428 October 1, 2026 17:28

@VegetarianOrc VegetarianOrc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Couple nits but nothing major.

Comment thread temporalio/nexus/_link_conversion.py Outdated
Comment on lines +60 to +66
def _link_path_regex(path: _LinkPath) -> re.Pattern[str]:
run_id = "[^/]+" if path.run_id_required else "[^/]*"
tail = f"/{path.tail}" if path.tail else ""
return re.compile(
rf"^/namespaces/(?P<namespace>[^/]+)/{path.keyword}"
rf"/(?P<id>[^/]+)/(?P<run_id>{run_id}){tail}$"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

small nit, but could/should this be a method on _LinkPath?

Comment thread temporalio/nexus/_link_conversion.py Outdated
) -> tuple[dict[str, str], dict[str, list[str]]] | None:
def _parse_link_url(
link: nexusrpc.Link, link_type: _LinkType
) -> tuple[str, str, str, dict[str, list[str]]] | None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit here as well: I think I'd prefer a frozen dataclass over the tuple of many things.

@Evanthx
Evanthx requested a review from VegetarianOrc October 3, 2026 00:22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog PR changes do not require changelog updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants