Unified link converter methods - #3068
Open
Evanthx wants to merge 2 commits into
Open
Conversation
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.
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. The changes to the Java SDK behavior are:
Query values are read from the raw query string
Previously parseQueryParams used uri.getQuery(), which is already percent-decoded, then decoded it a second time. Any value containing % made URLDecoder throw and the link was silently dropped; splitting on &/= after decoding also mis-split values containing those characters. Only reason had been moved to the raw query. Now every param is read from getRawQuery().
Aligns with: .NET (reads raw uri.Query); api-go, Python and TypeScript are correct by construction.
Path segment count is matched exactly — trailing segments and trailing slashes rejected
The StringTokenizer walk stopped checking once it had the segments it needed, so .../run-id/history/extra and .../run-id/history/ both parsed.
Aligns with: api-go and Python (anchored regexes), .NET (exact segment count).
Every decoder validates the declared link type
Three of the four already did; nexusLinkToWorkflowEvent did not, so a mistyped link passed straight to it would parse instead of being refused. No in-repo caller is affected — they all go through the dispatcher.
Aligns with: api-go and .NET, which check on every decoder.
A repeated query key takes its first occurrence
Previously inconsistent: reason took the first (rawQueryParam returns on match) while the workflow-event params took the last (HashMap.put). Now uniformly first.
Aligns with: api-go (url.Values.Get). Python and .NET reject duplicates outright. No encoder emits a repeated key.