Skip to content

[rust] Return error for out-of-range server API versions - #4244

Merged
fresh-borzoni merged 1 commit into
apache:mainfrom
slfan1989:fluss-4241
Sep 10, 2026
Merged

[rust] Return error for out-of-range server API versions#4244
fresh-borzoni merged 1 commit into
apache:mainfrom
slfan1989:fluss-4241

Conversation

@slfan1989

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #4241

ServerApiVersions::new() converted the api_key, min_version, and max_version fields received from the server from i32 to i16 using unwrap().

An out-of-range value in the server's ApiVersionsResponse could therefore panic the Rust client during connection establishment.

This change makes invalid server API version values return a descriptive error instead of causing a panic.

Brief change log

  • Change ServerApiVersions::new() to return Result<ServerApiVersions, Error>.
  • Replace the integer conversion unwrap() calls with checked conversions.
  • Include the invalid field name and value in the returned error.
  • Preserve the conversion error as the error source.
  • Propagate validation errors through the API version handshake.
  • Add unit tests for out-of-range:
    • api_key
    • min_version
    • max_version

Tests

Manually ran the unit tests.

cargo test -p fluss-rs --all-targets

API and Format

No.

Documentation

No.

@fresh-borzoni fresh-borzoni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@slfan1989 Thank you for the PR, LGTM 👍

@fresh-borzoni
fresh-borzoni merged commit 6ff6ab8 into apache:main Sep 10, 2026
21 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.

[Rust] Return error for out-of-range server API version values

2 participants