Skip to content

ArrowReader crashes on malformed input due to force unwraps #182

Description

@maltzsama

Describe the bug, including details regarding any error messages, version, and platform.

Description

ArrowReader.readStreaming(), ArrowReader.readFile(), and ArrowReader.fromMessage() crash with fatal errors when processing malformed or truncated Arrow files instead of returning error results.

Root Cause

Multiple locations in the reader use force unwrap (!) on optional values that can be nil when input is malformed:

  1. readStreaming (line 285-289): Assumes schemaMessage and result.schema exist before using them
  2. readFile (line 338, 374-375): Assumes footer.schema and result.schema exist without checking
  3. fromMessage (line 436): Assumes result.messageSchema and result.schema exist

When these values are nil (due to missing/malformed schema, missing recordbatch header, etc.), the force unwrap causes a crash instead of returning a .failure result.

Example Triggers

  • RecordBatch message without preceding Schema message
  • Truncated file missing footer schema
  • Malformed message headers

Expected Behavior

All malformed input should gracefully return ArrowError rather than crashing the application.

Affected Methods

  • readStreaming(_:useUnalignedBuffers:)
  • readFile(_:useUnalignedBuffers:)
  • fromMessage(_:dataBody:result:useUnalignedBuffers:)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions