Skip to content

fix: correct GetStats unsupported error message#1695

Closed
wxyucs wants to merge 1 commit intomainfrom
yellow/getstats-error-message
Closed

fix: correct GetStats unsupported error message#1695
wxyucs wants to merge 1 commit intomainfrom
yellow/getstats-error-message

Conversation

@wxyucs
Copy link
Collaborator

@wxyucs wxyucs commented Mar 13, 2026

Use a precise GetStats error text and add a regression assertion so callers are not misled by range-search wording.

Use a precise GetStats error text and add a regression assertion so callers are not misled by range-search wording.

Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com>
@wxyucs wxyucs requested review from LHT129, Copilot and inabao March 13, 2026 08:45
@wxyucs wxyucs self-assigned this Mar 13, 2026
@wxyucs wxyucs requested a review from jiaweizone as a code owner March 13, 2026 08:45
@wxyucs wxyucs added kind/bug Something isn't working version/1.0 labels Mar 13, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an inaccuracy in an error message and enhances test coverage. It ensures that when the GetStats method is called on an Index that does not support it, the error message clearly indicates the unsupported operation, rather than a misleading message about "range search". This change improves the clarity of error reporting and adds a robust regression test to maintain this correctness.

Highlights

  • Error Message Correction: The GetStats method's std::runtime_error message was updated from "Index not support range search" to "Index not support GetStats" to accurately reflect the unsupported operation.
  • Regression Test Addition: A new test case was added in test_simple_index.cpp to specifically catch the std::runtime_error thrown by GetStats and assert that its what() message matches the corrected string, preventing future regressions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • include/vsag/index.h
    • Updated the std::runtime_error message in the GetStats method to "Index not support GetStats".
  • tests/test_simple_index.cpp
    • Replaced a generic REQUIRE_THROWS for GetStats with a try-catch block.
    • Asserted that the std::runtime_error::what() message from GetStats is exactly "Index not support GetStats".
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a misleading error message in the GetStats method and adds a corresponding regression test. The changes are accurate and improve the codebase. I've provided one suggestion on the test implementation to make it more concise and idiomatic by using a built-in feature of the catch2 testing framework, which would improve the test's readability.

Comment on lines +119 to +124
try {
index->GetStats();
FAIL("Expected GetStats to throw");
} catch (const std::runtime_error& e) {
REQUIRE(std::string(e.what()) == "Index not support GetStats");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this try-catch block is correct, it can be simplified by using the REQUIRE_THROWS_WITH macro from catch2. This makes the test more concise and idiomatic.

Note that REQUIRE_THROWS_WITH with a string literal performs a case-sensitive substring match. For this particular error message, a substring match is likely sufficient. If an exact match is strictly required, you can use catch2 matchers like Catch::Matchers::Equals(...), which may require including an additional header.

    REQUIRE_THROWS_WITH(index->GetStats(), "Index not support GetStats");

Copy link
Contributor

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 corrects the default “unsupported” error message for Index::GetStats() and adds a regression assertion so callers/tests are no longer misled by the previous range-search wording.

Changes:

  • Update Index::GetStats() default implementation to throw std::runtime_error("Index not support GetStats").
  • Strengthen test_simple_index to assert the thrown exception message for GetStats().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/test_simple_index.cpp Replaces a generic REQUIRE_THROWS with an explicit assertion on the GetStats() exception text.
include/vsag/index.h Fixes the default GetStats() unsupported-operation error message.

Comment on lines +119 to +123
try {
index->GetStats();
FAIL("Expected GetStats to throw");
} catch (const std::runtime_error& e) {
REQUIRE(std::string(e.what()) == "Index not support GetStats");
@wxyucs wxyucs closed this Mar 16, 2026
@wxyucs wxyucs deleted the yellow/getstats-error-message branch March 16, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants