ShivamSharma43 opened a new pull request, #1549: URL: https://github.com/apache/arrow-go/pull/1549
### Rationale for this change `Writer.WriteMetadata` sends a `FlightData` message that has `app_metadata` but no IPC header or body. `NewRecordReader` dropped the first such message while peeking for a descriptor, but the message adapter passed any later one to `ipc.NewMessage`. The empty header then reached the flatbuffers decoder, and reading failed with: ``` arrow/flight: could not create flight reader: arrow/ipc: unknown error while reading: runtime error: index out of range [3] with length 0 ``` So two heartbeats before the schema broke the stream (see #1517). A single metadata-only message between two record batches failed the same way, because `Next()` hit the same decode error. ### What changes are included in this PR? `dataMessageReader.Message()` now skips messages that have neither a `DataHeader` nor a `DataBody`. It still records any `FlightDescriptor` they carry. Messages with a header, or with a body and no header, follow the same path as before. `LatestAppMetadata()` still returns the metadata attached to the record batch that was read, not the metadata of a skipped heartbeat. ### Are these changes tested? Yes. `TestReaderSkipsMetadataOnlyMessages` writes three `WriteMetadata` messages before the schema and one after each record batch (including after the last one). It then checks that every batch reads back equal, with its own `WriteWithAppMetadata` value, and that the stream ends cleanly. The test fails on `main` with the error above and passes with this change. `collectingFlightStreamWriter` now copies `AppMetadata` too, so the test can check it. `go test ./arrow/flight/...` passes, with and without `-tags assert,test -short`. `go vet ./arrow/flight/...` and gofmt are clean. ### Are there any user-facing changes? Readers no longer fail on streams that contain standalone metadata messages. The record-oriented reader skips those messages. Fixes #1517 AI assistance: I used Claude Code (Anthropic) to write this change and the test. I reviewed the code and ran the tests locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
