fix(workflow): report truncated=True when _truncate_array drops or shortens array elements#37193
Open
lalala223 wants to merge 1 commit into
Open
Conversation
…ortens elements VariableTruncator._truncate_array could return truncated=False even though array data was actually dropped or shortened, in two cases: 1. When the running size exceeds the limit, the loop stops and skips all the remaining elements, but it did not set truncated=True. The element-count limit a few lines above already returns truncated=True when it drops elements, so the two drop paths were inconsistent. 2. The flag was reassigned on every element instead of OR-ed together, so an element that fit after a truncated one reset it back to False. The two sibling methods, truncate_variable_mapping and _truncate_object, already accumulate the flag correctly; this aligns _truncate_array with them. The flag is exposed as inputs_truncated/outputs_truncated on the streaming node events, so a false negative reports truncated node values as untruncated. Added regression tests that fail before this change and pass after.
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.
Fixes #37192
Summary
VariableTruncator._truncate_arraycould returntruncated=Falseeven though array data was actually dropped or shortened, in two cases:breaks and discards the remaining elements, buttruncatedwas left unset. The element-count-limit branch a few lines above already returnsTruein the same situation.Trueback toFalse.The fix mirrors the existing correct pattern in the sibling methods
truncate_variable_mappingand_truncate_object, which accumulate the flag.The flag funnels into
inputs_truncated/outputs_truncatedon the streaming node events, so a false negative reports truncated node values as untruncated. Impact is minor/cosmetic — the finalworkflow_finishedoutput is not truncated and no data is lost.Screenshots
Same input (
{"result": [10, 20, 30, 40, 50]}, smallWORKFLOW_VARIABLE_TRUNCATION_MAX_SIZE),node_finishedevent:"outputs":{"result":[10]}, "outputs_truncated":false"outputs":{"result":[10]}, "outputs_truncated":trueChecklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint gods