Skip to content

feat: S24.09 StreamSender bad-setup contract — reject NULL Resolver/Stream/Address#455

Merged
DavidCozens merged 6 commits into
mainfrom
feat/s24-09-streamsender-bad-setup
May 25, 2026
Merged

feat: S24.09 StreamSender bad-setup contract — reject NULL Resolver/Stream/Address#455
DavidCozens merged 6 commits into
mainfrom
feat/s24-09-streamsender-bad-setup

Conversation

@DavidCozens

@DavidCozens DavidCozens commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

Brings SolidSyslogStreamSender_Create to the same bad-setup posture as SolidSyslogUdpSender_Create (S12.06). NULL config, Resolver, Stream, or Address now each emit a distinct SolidSyslog_Error(SEVERITY_ERROR, …) and resolve to the shared SolidSyslogNullSender without consuming a pool slot.

  • New error codes: STREAMSENDER_ERROR_NULL_{CONFIG,RESOLVER,STREAM,ADDRESS} — naming matches the UDPSENDER_ERROR_NULL_* convention, ordered to match the SolidSyslogStreamSenderConfig field order.
  • _Create now routes through a new StreamSender_IsValidConfig helper modelled on UdpSender_IsValidConfig (SolidSyslogUdpSenderStatic.c:48-76).
  • New SolidSyslogStreamSenderBadSetup TEST_GROUP mirrors the SolidSyslogUdpSenderBadSetup pair — one test per NULL path, plus crash-safety tests proving Send (drops on floor, returns true) and Disconnect (no-op) are safe through the returned NullSender handle.
  • CLAUDE.md SolidSyslogStreamSender.h row tail now reads "Pool-exhaustion and bad-config fallback is the shared SolidSyslogNullSender" — matching the UdpSender row.

SolidSyslogStreamSenderConfig.Endpoint is intentionally left optional (existing NoEndpointConfiguredConnectsToPortZero test pins this), so unlike UdpSender there is no NULL_ENDPOINT code.

Slice trail

  • 17d7d92 — Slice 1: NULL_CONFIG + the helper skeleton
  • bf63d72 — Slice 2: NULL_RESOLVER / NULL_STREAM / NULL_ADDRESS
  • d150e2e — Slice 3: crash-safety on the bad-setup handle
  • cc7fac1 — Slice 4: CLAUDE.md row

Test plan

  • build-linux-gcc — full StreamSender suite green (StreamSender, Destroy, Config, Failure, Pool, BadSetup)
  • build-linux-clang
  • sanitize-linux-gcc — ASan/UBSan clean across all StreamSender groups
  • analyze-format
  • analyze-tidy
  • analyze-cppcheck (standard)
  • cppcheck-misra (CI invocation verbatim) — clean, no misra_suppressions.txt changes
  • CI: build-windows-msvc, integration-{linux,windows}-openssl, BDD jobs, analyze-iwyu

Closes #424

Summary by CodeRabbit

  • Documentation

    • Updated stream sender fallback documentation to clarify behavior for pool exhaustion and bad configuration scenarios.
  • Bug Fixes

    • Enhanced error handling with four new error codes for null config, resolver, stream, and address validation.
    • Added configuration validation before pool acquisition.
  • Tests

    • Extended test coverage for bad setup scenarios, including null configuration and missing required fields.

Review Change Stack

Introduces StreamSender_IsValidConfig in the UdpSender shape and routes
_Create through it. NULL config now emits SolidSyslog_Error(ERROR,
STREAMSENDER_ERROR_NULL_CONFIG) and resolves to the shared
SolidSyslogNullSender — no pool slot consumed.

This is the first of four NULL-path slices that bring StreamSender to
the same bad-setup contract as UdpSender (S12.06).
…Sender_Create

Extends StreamSender_IsValidConfig with the three remaining NULL paths
under the bad-setup contract: NULL Resolver, NULL Stream, NULL Address
each emit SolidSyslog_Error(ERROR) with the matching
STREAMSENDER_ERROR_NULL_* code and resolve to the shared
SolidSyslogNullSender. Order matches SolidSyslogStreamSenderConfig
field order.
…andle

Mirrors the UdpSenderBadSetup pair: a sender returned from
SolidSyslogStreamSender_Create on a bad config is the shared
SolidSyslogNullSender, so Send returns true (drop-on-floor) and
Disconnect is a safe no-op.
CLAUDE.md's StreamSender row now mirrors the UdpSender row's wording —
both pool exhaustion and bad config (NULL config / Resolver / Stream /
Address) resolve to the shared SolidSyslogNullSender.
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@DavidCozens, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 18 minutes and 46 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db8584e9-2bc9-4a0e-8f98-7ef82581f931

📥 Commits

Reviewing files that changed from the base of the PR and between cc7fac1 and 96efbc7.

📒 Files selected for processing (1)
  • Tests/SolidSyslogStreamSenderTest.cpp
📝 Walkthrough

Walkthrough

This PR implements the bad-setup validation contract for SolidSyslogStreamSender_Create, bringing it to parity with SolidSyslogUdpSender. The change validates config and required fields (Resolver, Stream, Address) before pool acquisition, emitting distinct error codes and falling back to the shared null sender on failure.

Changes

StreamSender bad-setup validation

Layer / File(s) Summary
Error codes and message strings
Core/Interface/SolidSyslogStreamSenderErrors.h, Core/Source/SolidSyslogStreamSenderMessages.c
Four new error constants added to the SolidSyslogStreamSenderErrors enum for NULL config, resolver, stream, and address conditions, with corresponding message strings in the error lookup table.
Validation logic and fallback behavior
Core/Source/SolidSyslogStreamSenderStatic.c, CLAUDE.md
New StreamSender_IsValidConfig helper validates config pointer and required sub-pointers, emitting SolidSyslog_Error for each NULL case. SolidSyslogStreamSender_Create now calls this helper before pool acquisition; validation failure returns SolidSyslogNullSender without consuming a pool slot. Documentation updated to note both pool-exhaustion and bad-config fallback.
Bad-setup test suite
Tests/SolidSyslogStreamSenderTest.cpp
New SolidSyslogStreamSenderBadSetup test group with ErrorHandlerFake verifies the four NULL-rejection paths emit correct severity, source, and error codes. Additional tests confirm the bad-setup sender safely handles Send (returns true) and Disconnect without crashing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 A sender born with validation true,
Now rejects the NULL and broken through,
Pool spared when config's incomplete—
Null fallback makes the contract sweet! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding validation to reject NULL Resolver/Stream/Address in StreamSender, aligning with the bad-setup contract.
Description check ✅ Passed The PR description comprehensively covers all required sections: Purpose (references issue #424), Change Description (details validation logic, new error codes, and test coverage), Test Evidence (documents test groups and checklist), and Areas Affected (lists modified files and modules).
Linked Issues check ✅ Passed All acceptance criteria from issue #424 are met: NULL validation for config/Resolver/Stream/Address with distinct error codes, early return of NullSender without pool consumption, new BadSetup test coverage mirroring UDP tests, CLAUDE.md documentation updated, and no breaking changes to valid configurations.
Out of Scope Changes check ✅ Passed All changes directly support issue #424 requirements: error codes and validation logic in SolidSyslogStreamSenderErrors.h/.c, StreamSender config validation in SolidSyslogStreamSenderStatic.c, test coverage in SolidSyslogStreamSenderTest.cpp, and documentation in CLAUDE.md. No unrelated changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/s24-09-streamsender-bad-setup

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1344 passed)
   🚦   build-freertos-host-tdd: 100% successful (✔️ 1578 passed)
   🚦   build-linux-clang: 100% successful (✔️ 1296 passed)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1296 passed)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 7 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 9 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 46 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 90% successful (✔️ 44 passed, 🙈 5 skipped)
   🚦   bdd-freertos-qemu: 86% successful (✔️ 42 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1149 passed)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1296 passed)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: 1 warning (low: 1)


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
Tests/SolidSyslogStreamSenderTest.cpp (1)

771-808: ⚡ Quick win

DRY the repeated bad-setup assertions with a CHECK_* macro/helper.

The four NULL-path tests duplicate the same severity/source/code assertion shape; extracting one CHECK_STREAMSENDER_BAD_SETUP_ERROR(expectedCode) macro would align with the test-style rules and reduce drift risk.

As per coding guidelines: “Use CHECK_* macros for repeated assertion shapes in test code” and “DRY the setup, DRY the asserts, keep the test body small.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Tests/SolidSyslogStreamSenderTest.cpp` around lines 771 - 808, The four tests
(SolidSyslogStreamSenderBadSetup::CreateWithNullConfigReportsError,
::CreateWithNullResolverReportsError, ::CreateWithNullStreamReportsError,
::CreateWithNullAddressReportsError) duplicate the same post-call assertions;
create a CHECK_STREAMSENDER_BAD_SETUP_ERROR(expectedCode) test helper macro that
encapsulates the three assertions (CALLED_FAKE(ErrorHandlerFake_Handle, ONCE),
LONGS_EQUAL(SOLIDSYSLOG_SEVERITY_ERROR, ErrorHandlerFake_LastSeverity()),
POINTERS_EQUAL(&StreamSenderErrorSource, ErrorHandlerFake_LastSource()), and
UNSIGNED_LONGS_EQUAL(expectedCode, ErrorHandlerFake_LastCode())) and replace the
repeated assertion blocks in each test with a single call to that macro
immediately after the SolidSyslogStreamSender_Create(...) invocation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Tests/SolidSyslogStreamSenderTest.cpp`:
- Around line 771-808: The four tests
(SolidSyslogStreamSenderBadSetup::CreateWithNullConfigReportsError,
::CreateWithNullResolverReportsError, ::CreateWithNullStreamReportsError,
::CreateWithNullAddressReportsError) duplicate the same post-call assertions;
create a CHECK_STREAMSENDER_BAD_SETUP_ERROR(expectedCode) test helper macro that
encapsulates the three assertions (CALLED_FAKE(ErrorHandlerFake_Handle, ONCE),
LONGS_EQUAL(SOLIDSYSLOG_SEVERITY_ERROR, ErrorHandlerFake_LastSeverity()),
POINTERS_EQUAL(&StreamSenderErrorSource, ErrorHandlerFake_LastSource()), and
UNSIGNED_LONGS_EQUAL(expectedCode, ErrorHandlerFake_LastCode())) and replace the
repeated assertion blocks in each test with a single call to that macro
immediately after the SolidSyslogStreamSender_Create(...) invocation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 229081f4-d90b-414f-bc76-fd0ad1b6c833

📥 Commits

Reviewing files that changed from the base of the PR and between 4b3a361 and cc7fac1.

📒 Files selected for processing (5)
  • CLAUDE.md
  • Core/Interface/SolidSyslogStreamSenderErrors.h
  • Core/Source/SolidSyslogStreamSenderMessages.c
  • Core/Source/SolidSyslogStreamSenderStatic.c
  • Tests/SolidSyslogStreamSenderTest.cpp

- IWYU: drop unused #include "SolidSyslogError.h". SOLIDSYSLOG_SEVERITY_ERROR
  comes from SolidSyslogPrival.h; &StreamSenderErrorSource only needs the
  struct forward-decl from SolidSyslogStreamSenderErrors.h.
- cppcheck: suppress unreadVariable on the BadSetup setup()'s config
  assignment, matching the existing pattern in the SolidSyslogStreamSenderDestroy
  group — cppcheck does not model CppUTest macros so the field appears
  unread inside setup().
@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1344 passed)
   🚦   build-freertos-host-tdd: 100% successful (✔️ 1578 passed)
   🚦   build-linux-clang: 100% successful (✔️ 1296 passed)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1296 passed)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 7 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 9 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 46 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 90% successful (✔️ 44 passed, 🙈 5 skipped)
   🚦   bdd-freertos-qemu: 86% successful (✔️ 42 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1149 passed)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1296 passed)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: 1 warning (low: 1)


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

Each of the four NULL-path tests in SolidSyslogStreamSenderBadSetup
repeated the same four-line assertion block (CALLED_FAKE handle count,
severity, source pointer, error code). Lift them into a single
CHECK_STREAMSENDER_BAD_SETUP_ERROR(expectedCode) macro — same shape as
CHECK_PRIVAL / CHECK_BLOCK_CONTAINS elsewhere in the test suite.

Macro (not function) so failures report the caller's __FILE__/__LINE__;
do/while(0) wrapped for safe single-statement use.
@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1344 passed)
   🚦   build-freertos-host-tdd: 100% successful (✔️ 1578 passed)
   🚦   build-linux-clang: 100% successful (✔️ 1296 passed)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1296 passed)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 7 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 9 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 46 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 90% successful (✔️ 44 passed, 🙈 5 skipped)
   🚦   bdd-freertos-qemu: 86% successful (✔️ 42 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1149 passed)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1296 passed)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: 1 warning (low: 1)


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@DavidCozens DavidCozens merged commit 25bdfe7 into main May 25, 2026
21 checks passed
@DavidCozens DavidCozens deleted the feat/s24-09-streamsender-bad-setup branch May 25, 2026 16:50
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.

S24.09: StreamSender bad-setup contract — reject NULL Resolver / Stream / Address

1 participant