[Bug] Python NumpyTablet silently drops trailing zero bytes from BLOB values
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Read the Python client’s NumpyTablet and TSDataType.BLOB.np_dtype() implementations, then check the BLOB serialization path alongside Tablet.get_binary_values(). Reproduce the issue with the supplied example and compare the encoded payloads. Done means NumPy-backed BLOB values retain trailing zero bytes, the payload matches Tablet, and non-byte scalar coercion remains covered by a test.
Written by the indexing model from the issue text.
Description
Search before asking
- I searched the existing issues for NumpyTablet and BLOB truncation.
Version
Python client from master at 24d22d21ade21e2c9c2e2f04a742e93d7e51df54, Python 3.13.14, NumPy 2.5.5, macOS 15.3.2 arm64.
Minimal reproduction
Run this with the Python client on the import path. It inspects the value bytes used by the insert request and runs without a database.
import numpy as np
from iotdb.utils.IoTDBConstants import TSDataType
from iotdb.utils.NumpyTablet import NumpyTablet
from iotdb.utils.Tablet import Tablet
blob = bytes.fromhex("41 00 00")
columns = ["payload"]
types = [TSDataType.BLOB]
numpy_tablet = NumpyTablet(
"root.test.d", columns, types, [np.array([blob], dtype=object)], np.array([1])
)
tablet = Tablet("root.test.d", columns, types, [[blob]], [1])
print(numpy_tablet.get_binary_values().hex(" "))
print(tablet.get_binary_values().hex(" "))
Expected result
Both calls should print 00 00 00 03 41 00 00. The first four bytes encode the length, followed by the three original BLOB bytes.
Actual result
NumpyTablet prints 00 00 00 01 41. The regular Tablet prints 00 00 00 03 41 00 00. The NumPy path silently changes the length and contents before the request reaches the server.
Cause and proposed fix
TSDataType.BLOB.np_dtype() returns bytes, so the tablet converts the object column into NumPy's fixed-width byte-string representation. Accessing an element then strips trailing NUL bytes before serialization computes its length.
Use an object dtype for BLOB columns so that each Python bytes value retains its own length until serialization. Callers can use dtype=TSDataType.BLOB.np_dtype() when creating the array. Preserve the existing coercion of non-byte scalars and test the encoded payload against Tablet. An existing fixed-width S array has already lost the distinction between trailing zeros and padding.
Are you willing to submit a PR?
- Yes.
- Dominant language
- Java
- Stars
- 6.4k
- Forks
- 1.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 284
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iotdb
-
[Bug] sbin/replace-conf-from-env.sh word-splits the whole environment and corrupts iotdb-system.propertiesPossibly taken @anishmehta24 claimed this 69 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/iotdb#18655 · 1 reaction ·
Maintainers usually reply within 1 day
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports successPossibly taken @PDGGK claimed this 88 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column namePossibly taken @PDGGK claimed this 130 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[Bug] ResultSetMetaData.getCatalogName throws IndexOutOfBoundsException instead of SQLException for out-of-range columnsPossibly taken @PDGGK claimed this 132 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openhab/openhab-addons#22512 ·
Maintainers usually reply within 1 day
-
help wanted maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/maven-project-info-reports-plugin#704 ·
Maintainers usually reply within 1 day
-
help wanted maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/maven-ejb-plugin#261 ·
Maintainers usually reply within 1 day
-
help wanted maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/maven-archetype#1086 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day