Skip to content

Handle empty and duplicate keys in the StreamPage batch pump - #3

Merged
michaelstaib merged 2 commits into
mst/stream-v2from
mst/primitives-pump-fixes
Sep 27, 2026
Merged

michaelstaib merged 2 commits into
mst/stream-v2from
mst/primitives-pump-fixes

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

This tightens two edge cases in the batch pump from #1. An empty key set now releases the source and the lifetime right away instead of holding them forever. Duplicate keys now throw a clear ArgumentException through ThrowHelper, and the message names the key. To make the empty case possible, the pump's public constructor became a static CreateAsync factory that returns null when there is nothing to serve. Reviewers should note that a duplicate-key throw still leaves disposal to the caller; the EF batch method in a later PR is required to de-duplicate keys before calling the pump.

Closed tickets: hc-fork-1-dno.4 (6b72e5b), hc-fork-1-dno.5 (d2e9ac0).

Stack: sits on #2 (end cursors and StreamPage cursor helpers, mst/cursors-streampage).

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 26, 2026 23:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Empty-key cleanup can leak the lifetime if source disposal throws.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR hardens StreamBatchPump for empty and duplicate key sets.

Changes:

  • Adds async factory creation with empty-key cleanup.
  • Rejects duplicate keys via ThrowHelper.
  • Updates tests for the new API and edge cases.
File Description
src/​GreenDonut/​test/​GreenDonut.Data.Tests/​StreamBatchPumpTests.cs Updates construction and adds edge-case tests
src/​GreenDonut/​src/​GreenDonut.Data.Primitives/​Internal/​ThrowHelper.cs Adds duplicate-key exception creation
src/​GreenDonut/​src/​GreenDonut.Data.Primitives/​Internal/​StreamBatchPump.cs Implements factory creation, cleanup, and duplicate validation

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

@michaelstaib
michaelstaib added this pull request to stack #7 September 27, 2026 10:23
@michaelstaib
michaelstaib force-pushed the mst/primitives-pump-fixes branch from d2e9ac0 to f930173 Compare September 27, 2026 20:58
Base automatically changed from mst/cursors-streampage to mst/stream-v2 September 27, 2026 21:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

@michaelstaib
michaelstaib merged commit aaee058 into mst/stream-v2 Sep 27, 2026
2 checks passed
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.

2 participants