In-Place Mutation of Internal `read_kwargs` in `ParquetDataNode._read_from_path` Leaks Filter Arguments Across Subsequent Reads
Bug : In-Place Mutation of Internal read_kwargs in ParquetDataNode._read_from_path Leaks Filter Arguments Across Subsequent Reads
1. File & Lines
- File:
taipy/core/data/parquet.py - Lines: 217–227
- Method:
ParquetDataNode._read_from_path(self, path=None, **read_kwargs)
2. Description & Real-World Impact
In Taipy Core, ParquetDataNode.read_with_kwargs(**read_kwargs) allows users and scenario execution tasks to query a slice of a parquet dataset on-demand (e.g. projection with columns=['col_a'] or partition pushdown filters).
In ParquetDataNode._read_from_path:
kwargs = properties[self.__READ_KWARGS_PROPERTY]
kwargs.update(
{
self.__ENGINE_PROPERTY: properties[self.__ENGINE_PROPERTY],
}
)
kwargs.update(read_kwargs)properties[self.__READ_KWARGS_PROPERTY] returns a direct reference to the mutable dictionary stored in the data node. Calling .update() modifies that dictionary in-place inside self.properties.
Consequently, once a task or user executes dn.read_with_kwargs(columns=["customer_id"]), that transient filter is permanently written to the node's properties. All subsequent generic dn.read() calls will forever only return ["customer_id"], breaking downstream pipeline tasks that depend on reading all columns. (Contrast this with _write_to_path in line 177 of the same file, which correctly creates a new dictionary kwargs = {...}).
3. Vulnerable Source Code
# taipy/core/data/parquet.py lines 217-227
properties = self.properties
kwargs = properties[self.__READ_KWARGS_PROPERTY] # <--- Direct reference, no .copy()
kwargs.update(
{
self.__ENGINE_PROPERTY: properties[self.__ENGINE_PROPERTY],
}
)
kwargs.update(read_kwargs) # <--- Mutates self.properties in-place!
return self._do_read_from_path(path, properties[self._EXPOSED_TYPE_PROPERTY], kwargs)4. Minimal Reproduction Script
import pandas as pd
from taipy.core.data.parquet import ParquetDataNode
# Create a ParquetDataNode instance
df = pd.DataFrame({"id": [1, 2], "name": ["A", "B"], "score": [95, 88]})
dn = ParquetDataNode("test_dn", properties={"path": "test.parquet"})
dn.write(df)
# Read 1: Task A only needs the 'id' column
sliced_df = dn.read_with_kwargs(columns=["id"])
print("Read 1 columns:", list(sliced_df.columns)) # ['id']
# Read 2: Task B needs all columns via standard read()
full_df = dn.read()
print("Read 2 columns:", list(full_df.columns))
# EXPECTED: ['id', 'name', 'score']
# ACTUAL: ['id'] <-- 'name' and 'score' are missing because Read 1 corrupted internal read_kwargs!5. Proposed Fix (Git Patch)
diff --git a/taipy/core/data/parquet.py b/taipy/core/data/parquet.py
index a8b9c0d..e1f2g3h 100644
--- a/taipy/core/data/parquet.py
+++ b/taipy/core/data/parquet.py
@@ -217,7 +217,7 @@ class ParquetDataNode(DataNode, _TabularDataNodeMixin):
properties = self.properties
- kwargs = properties[self.__READ_KWARGS_PROPERTY]
+ kwargs = properties[self.__READ_KWARGS_PROPERTY].copy()
kwargs.update(
{
self.__ENGINE_PROPERTY: properties[self.__ENGINE_PROPERTY],Source: Avaiga/taipy