fix(compose): pass through when field mapping input already matches target type#976
Open
barry3406 wants to merge 1 commit intocloudwego:mainfrom
Open
fix(compose): pass through when field mapping input already matches target type#976barry3406 wants to merge 1 commit intocloudwego:mainfrom
barry3406 wants to merge 1 commit intocloudwego:mainfrom
Conversation
…arget type buildFieldMappingConverter and buildStreamFieldMappingConverter panic when the incoming value is not a map[string]any, but in some workflow topologies the upstream node can emit a value that is already the converter's target type I (or a stream of I). Treat that case as a pass-through instead of a panic, mirroring the fix suggested in cloudwego#957 and applying it to the stream variant as well. Fixes cloudwego#957
f3f87f1 to
135a804
Compare
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.
What type of PR is this?
fix
Check the PR title.
<type>(optional scope): <description>(Optional) More detailed description for this PR:
en:
buildFieldMappingConverterpanics when the incoming value is not amap[string]any, but in some workflow topologies the upstream node can emit a value that is already the converter's target typeI(see #957 for the repro). @nswodewy-code also notedbuildStreamFieldMappingConverterhas the same asymmetry on the stream path.This PR treats the "already the target type" case as a pass-through in both the sync and stream variants, so the workflow no longer panics when a node happens to emit its successor's declared input type directly. If the input is neither
map[string]anynorI, the original panic is preserved.(Optional) Which issue(s) this PR fixes:
Fixes #957
Test plan
Added
compose/field_mapping_test.gowith six table-style cases covering:buildFieldMappingConverter: target-type input passes through,map[string]anyinput still converts, unrelated input still panics.buildStreamFieldMappingConverter: stream of target type passes through, stream ofmap[string]anystill converts, stream of an unrelated type still panics.Full suite:
go test ./... -count=1 -race -timeout=300s— all packages green.