Skip to content

fix(io): correct IO type name in AsyncIOParameter JSON constructor#1723

Open
LHT129 wants to merge 2 commits intoantgroup:mainfrom
LHT129:2026-03-18-修复-asyncioparameter-构造函数类型名错误

Hidden character warning

The head ref may contain hidden characters: "2026-03-18-\u4fee\u590d-asyncioparameter-\u6784\u9020\u51fd\u6570\u7c7b\u578b\u540d\u9519\u8bef"
Open

fix(io): correct IO type name in AsyncIOParameter JSON constructor#1723
LHT129 wants to merge 2 commits intoantgroup:mainfrom
LHT129:2026-03-18-修复-asyncioparameter-构造函数类型名错误

Conversation

@LHT129
Copy link
Collaborator

@LHT129 LHT129 commented Mar 19, 2026

Summary

Fix incorrect IO type name in AsyncIOParameter JSON constructor. The constructor was using IO_TYPE_VALUE_BUFFER_IO instead of IO_TYPE_VALUE_ASYNC_IO.

Changes

  • Changed IO_TYPE_VALUE_BUFFER_IO to IO_TYPE_VALUE_ASYNC_IO in the JSON constructor of AsyncIOParameter at src/io/async_io_parameter.cpp:26

Background

The JSON constructor was incorrectly passing IO_TYPE_VALUE_BUFFER_IO to the base class, while the default constructor correctly uses IO_TYPE_VALUE_ASYNC_IO. This was a copy-paste error that could cause:

  • Type identification issues when creating AsyncIOParameter from JSON configuration
  • Inconsistent behavior in ToJson() serialization/deserialization

Testing

  • All AsyncIO related unit tests pass
  • Build passes with make release

Related Issues

Fixes #1722

Checklist

  • Code follows VSAG coding style
  • All tests pass
  • PR description is clear

Copilot AI review requested due to automatic review settings March 19, 2026 06:52
@LHT129 LHT129 self-assigned this Mar 19, 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 a critical bug in the AsyncIOParameter class's JSON constructor. A copy-paste error led to the constructor incorrectly initializing its base class with a buffer IO type instead of an async IO type. This fix ensures proper type identification and consistent behavior during JSON serialization and deserialization, preventing potential runtime issues.

Highlights

  • JSON Constructor Fix: Corrected the AsyncIOParameter JSON constructor to use IO_TYPE_VALUE_ASYNC_IO instead of IO_TYPE_VALUE_BUFFER_IO when initializing the base IOParameter.

🧠 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.

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.

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.

@LHT129 LHT129 added kind/bug Something isn't working version/1.0 labels Mar 19, 2026
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 corrects an issue in the AsyncIOParameter JSON constructor where an incorrect IO type was being used. The change aligns the constructor with the rest of the class. I have included one suggestion to refactor the constructors using delegation. This would improve maintainability by reducing code duplication and help prevent similar errors from occurring in the future.

Comment on lines 25 to 28
AsyncIOParameter::AsyncIOParameter(const vsag::JsonType& json)
: IOParameter(IO_TYPE_VALUE_BUFFER_IO) {
: IOParameter(IO_TYPE_VALUE_ASYNC_IO) {
this->FromJson(json); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve maintainability and prevent similar copy-paste errors, consider using a delegating constructor. This follows the Don't Repeat Yourself (DRY) principle by ensuring the IO_TYPE_VALUE_ASYNC_IO is only specified in one place (the default constructor), which would have prevented the original bug.

AsyncIOParameter::AsyncIOParameter(const vsag::JsonType& json) : AsyncIOParameter() {
    this->FromJson(json);  // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good suggestion! Created follow-up commit to use delegating constructor pattern. See commit below.

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

Fixes a copy-paste error where AsyncIOParameter’s JSON constructor was initializing its base IOParameter with the wrong IO type constant, causing inconsistent type identification for JSON-based construction.

Changes:

  • Updated AsyncIOParameter(const vsag::JsonType&) to pass IO_TYPE_VALUE_ASYNC_IO to the IOParameter base constructor (matching the default constructor)

@LHT129 LHT129 force-pushed the 2026-03-18-修复-asyncioparameter-构造函数类型名错误 branch 2 times, most recently from e423c5a to bbf6987 Compare March 20, 2026 05:52
Use AsyncIOParameter() delegating constructor instead of directly
calling IOParameter(IO_TYPE_VALUE_BUFFER_IO), which was incorrect.

Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
@LHT129 LHT129 force-pushed the 2026-03-18-修复-asyncioparameter-构造函数类型名错误 branch from bbf6987 to f2f8aae Compare March 20, 2026 05:53
Copilot AI review requested due to automatic review settings March 20, 2026 05:53
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

Fixes incorrect IO type assignment when constructing AsyncIOParameter from JSON by ensuring it uses the same initialization path as the default constructor, aligning serialization/deserialization behavior and type identification.

Changes:

  • Replace incorrect base-class initialization (IO_TYPE_VALUE_BUFFER_IO) with delegating construction via AsyncIOParameter().
  • Keep JSON parsing behavior (FromJson(json)) unchanged after correct initialization.

AsyncIOParameter::AsyncIOParameter(const vsag::JsonType& json)
: IOParameter(IO_TYPE_VALUE_BUFFER_IO) {
: AsyncIOParameter() {
this->FromJson(json); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

FromJson appears to be virtual (per the NOLINT), and calling virtual functions from constructors can cause surprising behavior if AsyncIOParameter is used as a base class (virtual dispatch won’t reach further-derived overrides during base construction). Consider making the class final, making FromJson non-virtual, or moving JSON parsing into a non-virtual helper/static factory that runs after full object construction.

Suggested change
this->FromJson(json); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
CHECK_ARGUMENT(json.Contains(IO_FILE_PATH_KEY), "miss file_path param in async io type");
this->path_ = json[IO_FILE_PATH_KEY].GetString();

Copilot uses AI. Check for mistakes.
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
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.

[Bug] Fix incorrect IO type name in AsyncIOParameter JSON constructor

2 participants