Reject invalid record sizes and return malformed-input errors
Validate payload sizes before record/header writes and make header packing return io::Result when the total size overflows the format limit. Return located parse errors for invalid UTF-8 and timestamp year overflow. Validate cell timestamps consistently in full reads, selected reads, and hierarchy scans while retaining scan behavior for skipped text geometry. Add regression coverage for preserved writer outputs, padded metadata sizes, malformed strings, timestamp boundaries, bounded errors, and Python bindings. Document the fallible header packing API. Validation: all 97 Rust tests pass in debug and release; all 16 Python tests pass against the rebuilt native library.
This commit is contained in:
parent
df62677f5c
commit
31afef0529
1 changed files with 307 additions and 28 deletions
|
|
@ -85,6 +85,31 @@ class ArrowTests(unittest.TestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
arrow.read_cells_bytes(layout(), [[1.5, 2.5]])
|
||||
|
||||
def test_malformed_strings_and_years_raise_located_parse_errors(self):
|
||||
data = layout()
|
||||
cell = arrow.scan_bytes(data).field("cells")[0].as_py()[0]
|
||||
start = cell["struct_start_offset"]
|
||||
ranges = [[start, cell["struct_end_offset"]]]
|
||||
cases = [
|
||||
(38, b"\xff", "Invalid UTF-8"),
|
||||
(start + 32, b"\xff", "Invalid UTF-8"),
|
||||
]
|
||||
cases += [
|
||||
(offset, b"\x7f\xff", "Timestamp year")
|
||||
for offset in (10, 22, start + 4, start + 16)
|
||||
]
|
||||
for offset, value, message in cases:
|
||||
malformed = bytearray(data)
|
||||
malformed[offset:offset + len(value)] = value
|
||||
for read in (
|
||||
arrow.read_bytes,
|
||||
arrow.scan_bytes,
|
||||
lambda payload: arrow.read_cells_bytes(payload, ranges),
|
||||
):
|
||||
with self.subTest(offset=offset, reader=read):
|
||||
with self.assertRaisesRegex(PheonError, rf"at byte \d+: {message}"):
|
||||
read(malformed)
|
||||
|
||||
def test_import_failure_releases_both_native_outputs(self):
|
||||
releases = []
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue