fix: correct GetStats unsupported error message#1695
Conversation
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>
Summary of ChangesHello, 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 Highlights
🧠 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| try { | ||
| index->GetStats(); | ||
| FAIL("Expected GetStats to throw"); | ||
| } catch (const std::runtime_error& e) { | ||
| REQUIRE(std::string(e.what()) == "Index not support GetStats"); | ||
| } |
There was a problem hiding this comment.
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");There was a problem hiding this comment.
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 throwstd::runtime_error("Index not support GetStats"). - Strengthen
test_simple_indexto assert the thrown exception message forGetStats().
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. |
| try { | ||
| index->GetStats(); | ||
| FAIL("Expected GetStats to throw"); | ||
| } catch (const std::runtime_error& e) { | ||
| REQUIRE(std::string(e.what()) == "Index not support GetStats"); |
Use a precise GetStats error text and add a regression assertion so callers are not misled by range-search wording.