JSON/Data addition mutates overlapping list values in the left operand
Bug
Adding two JSON/Data objects with an overlapping list-valued key modifies the left operand. Reusing that input for another addition then accumulates duplicate elements. Adding an object to itself also modifies the original.
Reproduction
On release-1.13.0 at 16b891f02d894daafb9b67b772d45ec316868780:
from lfx.schema import Data
left = Data(data={"items": [1]})
right = Data(data={"items": [2]})
print((left + right).data) # {"items": [1, 2]}
print(left.data) # actual: {"items": [1, 2]}; expected: {"items": [1]}
print((left + right).data) # actual: {"items": [1, 2, 2]}; expected: {"items": [1, 2]}JSON.__add__ makes a shallow copy of self.data, then uses combined_data[key] += value. For lists, this extends the same object still held by the input. Using ordinary addition instead avoids mutating list operands and follows the method's documented addition/fallback behavior.
Reproduced locally on Windows / Python 3.12.14 with the actual LFX model. Two regression cases (distinct operands and self-addition) fail on the original implementation.
AI assistance: investigated and prepared with OpenAI Codex; the reproduction and tests were executed locally.
Source: langflow-ai/langflow