Skip to content

fix: Handle missing data field in SSE parsing.#503

Merged
kinyoklion merged 1 commit intomainfrom
rlamb/oob-check
Nov 12, 2025
Merged

fix: Handle missing data field in SSE parsing.#503
kinyoklion merged 1 commit intomainfrom
rlamb/oob-check

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Nov 12, 2025

Note

Fixes SSE parser to safely trim trailing newlines when no data, adds comprehensive parser unit tests, and updates build to use Debug for tests with improved sanitizer settings and logging.

  • SSE parsing:
    • Fix Event::trim_trailing_newline to guard empty data before trimming.
  • Tests:
    • Add comprehensive unit tests in libs/server-sent-events/tests/parser_test.cpp covering types, ids, multi-line data, comments, line endings, buffering, and edge cases.
  • Build:
    • CMakeLists.txt: log when sanitizers are enabled; add -fsanitize=bounds-strict for GNU.
    • scripts/build.sh: set CMAKE_BUILD_TYPE to Debug when testing is ON; pass it to CMake and echo config.

Written by Cursor Bugbot for commit 71866cd. This will update automatically on new commits. Configure here.

@kinyoklion kinyoklion force-pushed the rlamb/oob-check branch 3 times, most recently from 7a9ede0 to 0108195 Compare November 12, 2025 21:14
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
add_compile_definitions(LAUNCHDARKLY_USE_ASSERT)
if (LD_TESTING_SANITIZERS)
message(STATUS "LaunchDarkly: testing sanitizers enabled")
Copy link
Member Author

Choose a reason for hiding this comment

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

Extra logging to see when sanitizers are enabled.

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=bounds-strict")
Copy link
Member Author

Choose a reason for hiding this comment

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

Enable bounds sanitizer.


void Event::trim_trailing_newline() {
if (data[data.size() - 1] == '\n') {
if (!data.empty() && data[data.size() - 1] == '\n') {
Copy link
Member Author

Choose a reason for hiding this comment

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

Actual change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Make sure we set the tests to debug to allow for _GLIBCXX_DEBUG which will include bounds checking assertions.

@kinyoklion kinyoklion changed the title testing fix: Handle missing data payloads. Nov 12, 2025
@kinyoklion kinyoklion changed the title fix: Handle missing data payloads. fix: Handle empty data in SSE parsing. Nov 12, 2025
@kinyoklion kinyoklion changed the title fix: Handle empty data in SSE parsing. fix: Handle missing data field in SSE parsing. Nov 12, 2025
@kinyoklion kinyoklion marked this pull request as ready for review November 12, 2025 22:07
@kinyoklion kinyoklion requested a review from a team as a code owner November 12, 2025 22:07
@kinyoklion kinyoklion merged commit 03b1d11 into main Nov 12, 2025
47 of 48 checks passed
@kinyoklion kinyoklion deleted the rlamb/oob-check branch November 12, 2025 22:43
@github-actions github-actions bot mentioned this pull request Nov 12, 2025
kinyoklion pushed a commit that referenced this pull request Nov 12, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>launchdarkly-cpp-client: 3.11.1</summary>

##
[3.11.1](launchdarkly-cpp-client-v3.11.0...launchdarkly-cpp-client-v3.11.1)
(2025-11-12)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-sse-client bumped from 0.6.0 to 0.6.1
</details>

<details><summary>launchdarkly-cpp-server: 3.10.1</summary>

##
[3.10.1](launchdarkly-cpp-server-v3.10.0...launchdarkly-cpp-server-v3.10.1)
(2025-11-12)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-sse-client bumped from 0.6.0 to 0.6.1
</details>

<details><summary>launchdarkly-cpp-server-otel: 0.1.1</summary>

##
[0.1.1](launchdarkly-cpp-server-otel-v0.1.0...launchdarkly-cpp-server-otel-v0.1.1)
(2025-11-12)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-server bumped from 3.10.0 to 3.10.1
</details>

<details><summary>launchdarkly-cpp-server-redis-source: 2.2.2</summary>

##
[2.2.2](launchdarkly-cpp-server-redis-source-v2.2.1...launchdarkly-cpp-server-redis-source-v2.2.2)
(2025-11-12)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * launchdarkly-cpp-server bumped from 3.10.0 to 3.10.1
</details>

<details><summary>launchdarkly-cpp-sse-client: 0.6.1</summary>

##
[0.6.1](launchdarkly-cpp-sse-client-v0.6.0...launchdarkly-cpp-sse-client-v0.6.1)
(2025-11-12)


### Bug Fixes

* Handle missing data field in SSE parsing.
([#503](#503))
([03b1d11](03b1d11))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Publish patch releases for client/server SDKs and SSE client; update
dependencies to `launchdarkly-cpp-sse-client@0.6.1`, adjust version
constants/tests, and record SSE parsing bug fix.
> 
> - **Releases**:
>   - `libs/client-sdk`: `3.11.1`
>   - `libs/server-sdk`: `3.10.1`
>   - `libs/server-sdk-redis-source`: `2.2.2`
>   - `libs/server-sdk-otel`: `0.1.1`
>   - `libs/server-sent-events`: `0.6.1`
> - **Dependencies**:
> - Client/Server SDKs now depend on
`launchdarkly-cpp-sse-client@0.6.1`.
> - Redis Source and OTEL now depend on
`launchdarkly-cpp-server@3.10.1`.
> - **Code/version updates**:
> - Update SDK version constants and corresponding unit tests to new
versions.
>   - Update `.release-please-manifest.json` and package/CMake versions.
> - **Bug fix (SSE)**:
>   - Note fix for handling missing `data` field in SSE parsing.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e598876. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants