Skip to content

[StubGen] Fix input optional vector - #321

Closed
sebaszm wants to merge 29 commits into
masterfrom
development/fix-optional-vector
Closed

sebaszm wants to merge 29 commits into
masterfrom
development/fix-optional-vector

Conversation

@sebaszm

@sebaszm sebaszm commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings August 20, 2026 17:04
@sebaszm
sebaszm marked this pull request as draft August 20, 2026 17:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds functional-test coverage and corresponding test interface/implementation methods for handling optional std::vector<uint8_t> parameters, aligning with the stated goal of fixing optional vector input handling in StubGen/COMRPC functional tests.

Changes:

  • Added new COMRPC functional tests for optional vector output and in-place vector mutation.
  • Extended ITestOptionals with new optional vector methods.
  • Implemented the new optional vector methods in TestOptionalsImpl.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/FunctionalTests/comrpc/tests/TestOptionals.cpp Adds functional tests for optional vector and inline optional vector processing.
tests/FunctionalTests/common/interfaces/ITestOptionals.h Introduces interface methods for optional vector input/output and in-place processing.
tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp Implements the new optional vector interface methods.
Suppressed comments (2)

tests/FunctionalTests/comrpc/tests/TestOptionals.cpp:215

  • This test calls ProcessOptionalVector(data) but the interface defines ProcessOptionalInlineVector for in-place updates. The loop also uses sizeof(input) where 'input' is not in scope, so this will not compile.
    ASSERT_EQ(_proxy->ProcessOptionalVector(data), Core::ERROR_NONE);
    for (uint8_t i = 0; i < sizeof(input); i++) {
        EXPECT_EQ(data[i], copy[i]*2);

tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp:139

  • ProcessOptionalInlineVector uses an unqualified OptionalType and calls begin()/end() directly on the optional wrapper. To match the rest of the file and avoid compilation issues, it should use Core::OptionalType and operate on data.Value() only when the optional is set.
        Core::hresult ProcessOptionalInlineVector(
            OptionalType<std::vector<uint8_t>>& data) override
        {
            std::for_each(data.begin(), data.end(), [](int &num) {
                num *= 2;
            });
            return Core::ERROR_NONE;

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/FunctionalTests/comrpc/tests/TestOptionals.cpp Outdated
Comment thread tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp
Comment thread tests/FunctionalTests/common/interfaces/ITestOptionals.h Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Suppressed comments (2)

tests/FunctionalTests/comrpc/tests/TestOptionals.cpp:231

  • Same issue here: uint8_t as an index can wrap for vectors larger than 255 elements. Use size_t (or auto) for the index.
    for (uint8_t i = 0; i < copy.size(); i++) {

tests/FunctionalTests/comrpc/tests/TestOptionals.cpp:210

  • The loop counter is uint8_t but you compare it to input.size() (size_t). If the test vector grows beyond 255 elements, i will wrap and the loop can become incorrect or infinite. Use size_t (or auto) for the index and pre-increment.

This issue also appears on line 231 of the same file.

    for (uint8_t i = 0; i < input.size(); i++) {

Comment thread tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp
@github-actions

Copy link
Copy Markdown

LuaGenerator Results

View Results

No changes detected.

@github-actions

Copy link
Copy Markdown

LuaGenerator Results

View Results

No changes detected.

@github-actions

Copy link
Copy Markdown

ProxyStubGenerator Results

View Results

Changes detected.

@github-actions

Copy link
Copy Markdown

JsonGenerator Results

View Results

No changes detected.

@github-actions

Copy link
Copy Markdown

LuaGenerator Results

View Results

No changes detected.

@github-actions

Copy link
Copy Markdown

LuaGenerator Results

View Results

No changes detected.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

tests/FunctionalTests/common/implementations/TestOptionalsImpl.cpp:169

  • cp.data is empty here, but std::transform(..., cp.data.begin(), ...) writes through cp.data.begin() without resizing the destination first. This is undefined behavior and can crash or corrupt memory.

                std::transform(input.Value().data.begin(), input.Value().data.end(), cp.data.begin(), [](uint8_t x) {
                    return static_cast<uint8_t>(x * 2);

Comment thread tests/FunctionalTests/comrpc/tests/TestOptionals.cpp Outdated
Comment thread tests/FunctionalTests/common/interfaces/ITestOptionals.h
@sebaszm sebaszm closed this Aug 24, 2026
@sebaszm
sebaszm deleted the development/fix-optional-vector branch August 24, 2026 11:13
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants