Skip to content

Conversation

@SaathwikDasari
Copy link
Contributor

What is changed and how it works?

Replaced a panic-inducing .unwrap() on resp.leader with ok_or_else in src/pd/cluster.rs.

If resp.leader is None, the client will now return a proper error instead of crashing the entire application.

Issue reference

Closes #504

Check List

  • Code is formatted (ran cargo fmt? If not, run it locally now!)
  • This PR is signed-off

@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. contribution This PR is from a community contributor. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. labels Dec 30, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Dec 30, 2025

Welcome @SaathwikDasari!

It looks like this is your first PR to tikv/client-rust 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to tikv/client-rust. 😃

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 PR addresses a critical panic issue in the TiKV client library where calling .unwrap() on resp.leader caused application crashes when the leader was None. The fix replaces the panic-inducing unwrap with proper error handling using ok_or_else.

Key changes:

  • Replaced .unwrap() with .ok_or_else() to return a proper error instead of panicking
  • Added descriptive error message "no leader found in GetMembersResponse"

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

@pingyu
Copy link
Collaborator

pingyu commented Jan 2, 2026

The resp.leader must not be None. Otherwise, Connection::try_connect (and Connection::connect) will return error (see #452).

But I think it's still nice to have this change to make it more robust.

@SaathwikDasari Please fix the error of "CI / check". Rest LGTM.

@ti-chi-bot ti-chi-bot bot added dco-signoff: no Indicates the PR's author has not signed dco. and removed dco-signoff: yes Indicates the PR's author has signed the dco. labels Jan 2, 2026
Signed-off-by: Saathwik Dasari <saathwik.dasari@gmail.com>
Signed-off-by: Saathwik Dasari <saathwik.dasari@gmail.com>
@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. and removed dco-signoff: no Indicates the PR's author has not signed dco. labels Jan 2, 2026
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jan 4, 2026
@pingyu
Copy link
Collaborator

pingyu commented Jan 4, 2026

cc @iosmanthus

@ti-chi-bot ti-chi-bot bot added the lgtm label Jan 5, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jan 5, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iosmanthus, pingyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 5, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jan 5, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-04 01:34:12.379354884 +0000 UTC m=+493208.197663326: ☑️ agreed by pingyu.
  • 2026-01-05 09:14:31.803810942 +0000 UTC m=+607227.622119384: ☑️ agreed by iosmanthus.

@ti-chi-bot ti-chi-bot bot merged commit 54487d0 into tikv:master Jan 5, 2026
10 of 11 checks passed
@pingyu
Copy link
Collaborator

pingyu commented Jan 6, 2026

@SaathwikDasari Thanks for your contribution !

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

Labels

approved contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. lgtm size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option::unwrap() on a None` value /src/pd/cluster.rs:243:56: & 0.3.0/src/transaction/transaction.rs:1017:21:

3 participants