fix(api): accumulate truncated flag in _truncate_array - #39774
Open
agarwalpranav0711 wants to merge 1 commit into
Open
fix(api): accumulate truncated flag in _truncate_array#39774agarwalpranav0711 wants to merge 1 commit into
agarwalpranav0711 wants to merge 1 commit into
Conversation
agarwalpranav0711
requested review from
QuantumGhost and
laipz8200
as code owners
July 29, 2026 17:23
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-07-29 17:25:08.033178936 +0000
+++ /tmp/pyrefly_pr.txt 2026-07-29 17:24:58.714097611 +0000
@@ -8397,11 +8397,11 @@
ERROR Cannot set item in `dict[str, int]` [unsupported-operation]
--> tests/unit_tests/services/test_variable_truncator.py:142:31
ERROR Argument `list[File]` is not assignable to parameter `value` with type `list[object]` in function `services.variable_truncator.VariableTruncator._truncate_array` [bad-argument-type]
- --> tests/unit_tests/services/test_variable_truncator.py:724:44
+ --> tests/unit_tests/services/test_variable_truncator.py:731:44
ERROR Argument `list[File]` is not assignable to parameter `value` with type `list[object]` in function `services.variable_truncator.VariableTruncator._truncate_array` [bad-argument-type]
- --> tests/unit_tests/services/test_variable_truncator.py:736:44
+ --> tests/unit_tests/services/test_variable_truncator.py:743:44
ERROR Argument `list[File]` is not assignable to parameter `value` with type `list[object]` in function `services.variable_truncator.VariableTruncator._truncate_array` [bad-argument-type]
- --> tests/unit_tests/services/test_variable_truncator.py:751:44
+ --> tests/unit_tests/services/test_variable_truncator.py:758:44
ERROR Argument `dict[str, dict[Unknown, Unknown]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
--> tests/unit_tests/services/test_webhook_service.py:250:79
ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
|
Contributor
Pyrefly Type Coverage
|
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.
Important
Fixes #<issue number>.Summary
Fixes #39773
_truncate_arrayinapi/services/variable_truncator.pyuses a direct assignment (truncated = part_result.truncated) at line 304, which overwrites the truncation flag on every loop iteration. If an early array element is truncated but a later one fits within budget, the method incorrectly returnstruncated = False.The other two methods in the same file accumulate the flag correctly:
truncate_variable_mapping(line 136):is_truncated = is_truncated or part_result.truncated_truncate_object(lines 383-384):if value_result.truncated: truncated = TrueThis PR applies the same accumulating pattern to
_truncate_arrayand adds a targeted unit test.Changes
api/services/variable_truncator.py: Changedtruncated = part_result.truncated→truncated = truncated or part_result.truncatedapi/tests/unit_tests/services/test_variable_truncator.py: Addedtest_array_truncation_flag_accumulationto verify the flag staysTruewhen an early element is truncated but a later one is notScreenshots
N/A — backend-only logic fix, no UI changes.
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint gods