Skip to content

Fix panic / crashes in Rust and C++#365

Merged
luoyuxia merged 5 commits intoapache:mainfrom
leekeiabstraction:fix-rust-cpp-crash
Feb 27, 2026
Merged

Fix panic / crashes in Rust and C++#365
luoyuxia merged 5 commits intoapache:mainfrom
leekeiabstraction:fix-rust-cpp-crash

Conversation

@leekeiabstraction
Copy link
Contributor

@leekeiabstraction leekeiabstraction commented Feb 22, 2026

Purpose

Linked issue: close #361, #362

Fix panic / crashes in Rust and C++ when

  1. User call getters e.g. get_int on a column that is outside of legal index range or on wrong type
  2. User tries to append a row of wrong column width / type to a log table

Brief change log

  • Return error instead of panic-ing when using wrong typed getter on row column. Prevents panic and crashing Rust / C++. Bubble error through the layers.
  • Check column count before log append

Tests

Updated tests.

@leekeiabstraction
Copy link
Contributor Author

@fresh-borzoni Appreciate your review here 🙏

Copy link
Contributor

@charlesdong1991 charlesdong1991 left a comment

Choose a reason for hiding this comment

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

Nice PR!
i just started using fluss, and learn about the repo, I put a couple comments also to help myself to understand the repo better! ^^
thanks!

Copy link
Contributor

@fresh-borzoni fresh-borzoni left a comment

Choose a reason for hiding this comment

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

@leekeiabstraction Ty, left some comments.
PTAL

@leekeiabstraction
Copy link
Contributor Author

Thank you for the reviews and discussions. Pushed new rev PTAL @fresh-borzoni @luoyuxia

@leekeiabstraction
Copy link
Contributor Author

Missed some IT test changes, will push in my evening

@leekeiabstraction
Copy link
Contributor Author

Also appreciate if you can review again @charlesdong1991

Copy link
Contributor

@charlesdong1991 charlesdong1991 left a comment

Choose a reason for hiding this comment

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

A minor comment but i think if we wanna address, better to do in a follow up PR

Copy link
Contributor

@fresh-borzoni fresh-borzoni left a comment

Choose a reason for hiding this comment

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

@leekeiabstraction Ty, LGTM. Left some comments.
we may wish to just reorder schema.field with column fetch line to resolve this or some helper with bounds checks

@leekeiabstraction
Copy link
Contributor Author

@fresh-borzoni Nice catch, addressed!

Copy link
Contributor

@fresh-borzoni fresh-borzoni left a comment

Choose a reason for hiding this comment

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

@luoyuxia
Copy link
Contributor

luoyuxia commented Feb 25, 2026

Thanks @leekeiabstraction I'll have a final review tomorrow.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes critical panics and crashes in Rust and C++ bindings by adding proper error handling for row getter operations. The changes address two main issues: (1) calling typed getters (e.g., get_int) on columns with wrong types or out-of-bounds indices, and (2) appending rows with mismatched column counts or types to log tables.

Changes:

  • Modified InternalRow trait methods to return Result<T> instead of T, enabling error propagation instead of panics
  • Added field count validation in AppendWriter and UpsertWriter to catch schema mismatches early
  • Updated all implementations of InternalRow (GenericRow, CompactedRow, ColumnarRow) to return proper errors
  • Propagated error handling through all layers including field getters, encoders, and bindings

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/fluss/src/row/mod.rs Core trait change: InternalRow methods now return Result for error handling
crates/fluss/src/row/column.rs ColumnarRow implementation updated with bounds and type checking
crates/fluss/src/row/compacted/compacted_row.rs CompactedRow implementation updated with error handling
crates/fluss/src/row/field_getter.rs Field getter propagates errors from row accessors
crates/fluss/src/client/table/append.rs Added field count validation before appending rows
crates/fluss/src/client/table/upsert.rs Added field count validation before upserting rows
crates/fluss/tests/integration/log_table.rs Test updates with .unwrap() calls and new undersized_row test
crates/fluss/tests/integration/kv_table.rs Test updates with .unwrap() calls for error handling
bindings/python/src/table.rs Python binding updated to propagate errors
bindings/cpp/src/lib.rs C++ binding updated to convert errors to strings
examples/* Example code updated with proper error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

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

@leekeiabstraction Thanks for the pr. The code looks good to me. But please don't forget to update the documentation, which can be done in another pr.

@luoyuxia luoyuxia merged commit c7ad66d into apache:main Feb 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Appending row with mismatched column count / type crashes Rust / Cpp binding

5 participants