Skip to content

Fix crash on empty batch response in multi-entry queries#111

Merged
atimin merged 5 commits intomainfrom
copilot/fix-sdk-crash-empty-batch
Jan 24, 2026
Merged

Fix crash on empty batch response in multi-entry queries#111
atimin merged 5 commits intomainfrom
copilot/fix-sdk-crash-empty-batch

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

  • Understand the issue (SDK crashes on empty batch for multi-entry querying)
  • Locate the bug in ParseAndBuildBatchedRecordsV2 function
  • Fix the empty batch handling in batch_v2.cc (filter empty strings in ParseEncodedList)
  • Replace integration test with unit test that tests ParseAndBuildBatchedRecordsV2 directly
  • Remove all error message checks from tests (only check status codes)
  • Update CHANGELOG with PR reference
  • Run cpplint to ensure code style compliance
  • Build the code to verify compilation
  • Run tests to verify changes
  • Code review completed (no issues found)
  • CodeQL security scan completed (no vulnerabilities found)

Summary

Fixed SDK crash on empty batch for multi-entry querying by filtering empty strings in ParseEncodedList function. Replaced integration test with unit test that directly tests the parsing function. Removed all error message checks from tests (16 total), now only verifying status codes to avoid CI/CD failures when error messages change.

Security Summary

No security vulnerabilities were discovered or introduced by these changes.

Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: SDK crashes on empty batch for multi-entry querying</issue_title>
<issue_description>### What happened?
SDK crashes when multi-entry query receives an empty batch. Expected to accept empty batch (as fixed in reduct-py PR reductstore/reduct-py#156).

Version

Not specified

OS

Linux

Snippet to repeat the bug

See fix in reduct-py: reductstore/reduct-py#156

Logs

No logs.

Code of Conduct

  • I agree to follow this project's Code of Conduct</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 23, 2026 21:12
Co-authored-by: atimin <67068+atimin@users.noreply.github.com>

Co-authored-by: atimin <67068+atimin@users.noreply.github.com>
Co-authored-by: atimin <67068+atimin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SDK crash on empty batch for multi-entry querying Fix crash on empty batch response in multi-entry queries Jan 23, 2026
Copilot AI requested a review from atimin January 23, 2026 21:13
Copy link
Member

@atimin atimin left a comment

Choose a reason for hiding this comment

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

Update other tests what crashed in the CI/CD. Don't test messages only statuses. Update changeloge using the ID of the current PR.

REQUIRE(received == std::map<std::string, std::string>{{"entry-a", "aaa"}, {"entry-b", "bbb"}});
}

TEST_CASE("reduct::IBucket should handle empty batch for multi-entry query", "[entry_api][1_18]") {
Copy link
Member

Choose a reason for hiding this comment

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

test the function directly without the server, since it happens when a query timeouted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to test ParseAndBuildBatchedRecordsV2 directly with empty entries header. The unit test simulates an empty batch response without requiring a server. (e80f117)

- Test ParseAndBuildBatchedRecordsV2 directly without server
- Remove error message checks, only check status codes
- Update CHANGELOG with PR-110 reference

Co-authored-by: atimin <67068+atimin@users.noreply.github.com>

Co-authored-by: atimin <67068+atimin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 24, 2026

Update other tests what crashed in the CI/CD. Don't test messages only statuses. Update changeloge using the ID of the current PR.

Updated tests to check only status codes, not error messages. Updated CHANGELOG with PR-110 reference. (e80f117)

Copilot AI requested a review from atimin January 24, 2026 18:40
@atimin
Copy link
Member

atimin commented Jan 24, 2026

@copilot There are more tests broken because of error messages. Check only statuses.

- Update bucket_api_test.cc: 6 message checks removed
- Update entry_api_test.cc: 8 message checks removed
- Update server_api_test.cc: 2 message checks removed
- Fix error code for extension test (422 not 400)

Co-authored-by: atimin <67068+atimin@users.noreply.github.com>

Co-authored-by: atimin <67068+atimin@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 24, 2026

@copilot There are more tests broken because of error messages. Check only statuses.

Removed all remaining error message checks from tests. Updated 16 total message checks across bucket_api_test.cc, entry_api_test.cc, and server_api_test.cc to only verify status codes. (4f1cdbb)

@atimin atimin marked this pull request as ready for review January 24, 2026 20:55
@atimin atimin merged commit 9497055 into main Jan 24, 2026
18 checks passed
@atimin atimin deleted the copilot/fix-sdk-crash-empty-batch branch January 24, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: SDK crashes on empty batch for multi-entry querying

2 participants