Skip to content

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

Open
slfan1989 wants to merge 1 commit into
apache:mainfrom
slfan1989:fluss-4241
Open

[rust] Return error for out-of-range server API versions#4244
slfan1989 wants to merge 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.

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

1 participant