maltzsama opened a new pull request, #183:
URL: https://github.com/apache/arrow-swift/pull/183

   ## What's Changed
   
   `readStreaming`, `readFile`, and `fromMessage` force-unwrapped optional 
schema and message header values, causing crashes on malformed or out-of-order 
input instead of returning an `ArrowError`. For example, a RecordBatch message 
arriving with no preceding Schema message would crash the process rather than 
fail gracefully.
   
   Replaced the force unwraps with guard statements that return `.failure` 
instead:
   
   - `readStreaming`: guards on the RecordBatch header, `schemaMessage`, and 
`result.schema` before use
   - `readFile`: guards on `footer.schema`, the RecordBatch header, and 
`result.schema` before use
   - `fromMessage`: guards on the Schema header, the RecordBatch header, 
`result.messageSchema`, and `result.schema` before use
   
   ## Testing
   
   Added a regression test (`testReadStreamingRecordBatchBeforeSchema`) that 
builds a valid streaming payload, strips the Schema message, and confirms 
`readStreaming` now returns `.failure` instead of crashing.
   
   Full test suite passes (47 tests, 0 failures).
   
   ## Note
   
   While constructing the test, found that `readStreaming` also assumes 
zero-based `Data` indices internally — slicing with `data[offset...]` preserves 
the original absolute indices rather than resetting to zero, which can misalign 
offset-based reads elsewhere in the reader if not handled carefully by the 
caller. Flagging this for a possible follow-up issue; it did not need to be 
fixed here since the test works around it explicitly.
   
   Closes #182.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to