Skip to content

Commit c291839

Browse files
committed
fix: revert file_append empty-contents validation broken by integration test
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
1 parent 6259ff5 commit c291839

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

src/hiero_sdk_python/file/file_append_transaction.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ def _build_proto_body(self) -> file_append_pb2.FileAppendTransactionBody:
168168
# Calculate the current chunk's content
169169
if self.file_id is None:
170170
raise ValueError("Missing required FileID")
171-
if not self.contents:
172-
raise ValueError("Missing required file contents")
173171

174-
start_index = self._current_chunk_index * self.chunk_size
175-
end_index = min(start_index + self.chunk_size, len(self.contents))
176-
chunk_contents = self.contents[start_index:end_index]
172+
if self.contents is None:
173+
chunk_contents = b""
174+
else:
175+
start_index = self._current_chunk_index * self.chunk_size
176+
end_index = min(start_index + self.chunk_size, len(self.contents))
177+
chunk_contents = self.contents[start_index:end_index]
177178

178179
return file_append_pb2.FileAppendTransactionBody(
179180
fileID=self.file_id._to_proto() if self.file_id else None, contents=chunk_contents

tests/unit/file_append_transaction_test.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,6 @@ def test_build_transaction_body_missing_file_id():
159159
file_tx.build_transaction_body()
160160

161161

162-
def test_build_proto_body_raises_on_empty_contents():
163-
"""Test _build_proto_body raises when contents is None or empty."""
164-
file_id = FileId(0, 0, 99)
165-
166-
with pytest.raises(ValueError, match="Missing required file contents"):
167-
FileAppendTransaction(file_id=file_id)._build_proto_body()
168-
169-
with pytest.raises(ValueError, match="Missing required file contents"):
170-
FileAppendTransaction(file_id=file_id, contents=b"")._build_proto_body()
171-
172-
173162
def test_build_scheduled_body():
174163
"""Test building a schedulable file append transaction body."""
175164
file_id = FileId(0, 0, 12345)

0 commit comments

Comments
 (0)