Skip to content

fix(ffi): report the producer's C stream error message, don't unwrap it - #10844

Merged
Jefffrey merged 2 commits into
apache:mainfrom
fornwall:producer-message
Aug 26, 2026
Merged

fix(ffi): report the producer's C stream error message, don't unwrap it#10844
Jefffrey merged 2 commits into
apache:mainfrom
fornwall:producer-message

Conversation

@fornwall

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

No issue filed (this is a minor fix).

Rationale for this change

get_stream_schema discarded the producer's message entirely, reporting only the numeric return code, so a failed import left the consumer with nothing but an errno.

Iterator::next did the opposite, unwrapping the producer's message without checking there was one. The C stream interface lets get_last_error return NULL when no detailed description is available, so a conforming producer that reported a failure without a message made the consumer panic across an FFI boundary instead of returning an error.

What changes are included in this PR?

get_stream_schema and Iterator::next now includes the producer's error message when there is one.

Are these changes tested?

Yes. test_error_import now asserts the full message that a failing Rust producer surfaces through a round trip. New tests drive a hand-written producer through both the schema and the next path, covering: a producer message, get_last_error returning NULL, and a NULL get_last_error callback. The NULL-message case panicked before this change.

Are there any user-facing changes?

No API changes; error messages change:

  • A failed schema import previously read Cannot get schema from input stream. Error code: 5, and now appends . Producer error: <message> when the producer supplies one.
  • A failed next() previously surfaced the producer's message alone (e.g. Memory error: out of memory), and now reads Cannot get next batch from input stream. Error code: 12. Producer error: Memory error: out of memory.

AI usage: Created with claude code and opus 5. I have reviewed the code and iterated on it.

`get_stream_schema` discarded the producer's message entirely, reporting
only the numeric return code.

`Iterator::next` did the opposite, unwrapping the producer's message
without checking there was one. The C Stream Interface lets
`get_last_error` return NULL when no detailed description is available,
so a conforming producer that reported a failure without a message made
the consumer panic instead of returning an error.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-array labels Aug 25, 2026
@fornwall fornwall changed the title Report the producer's error message when importing a C stream fails fix(ffi): report the producer's C stream error message, don't unwrap it Aug 26, 2026

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, just a minor comment (applies for both unsafe usages)

Comment thread arrow-array/src/ffi_stream.rs
@Jefffrey Jefffrey added the bug label Aug 26, 2026
@fornwall
fornwall requested a review from Jefffrey August 26, 2026 11:05
@Jefffrey
Jefffrey merged commit bab409b into apache:main Aug 26, 2026
34 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @fornwall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-array bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants