fix(projections): reject oversized definitions#422
Conversation
yordis
commented
Jul 6, 2026
- Projection management requests should fail promptly when the persisted definition cannot fit in a log record.
- Callers need a deterministic validation error instead of waiting for a deadline after the management queue loses the reply path.
- Related projection operations should preserve their specific gRPC failure semantics instead of collapsing expected failures into unknown responses.
PR SummaryMedium Risk Overview
gRPC projection operations handle Reviewed by Cursor Bugbot for commit 75b79a7. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Review limit reached
Next review available in: 40 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
WalkthroughThis PR adds a ChangesOversized projection definition handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ProjectionManagement
participant ManagedProjection
participant Stream as ProjectionsStateStream
Client->>ProjectionManagement: Post/Update projection with oversized query
ProjectionManagement->>ManagedProjection: forward command
ManagedProjection->>ManagedProjection: TryCreatePersistedStateEvent (check size)
alt size exceeds EffectiveMaxLogRecordSize
ManagedProjection->>ManagedProjection: FailPersistedStateWrite (fault projection)
ManagedProjection-->>ProjectionManagement: OperationFailed(RecordTooLarge)
ProjectionManagement-->>Client: RpcException(InvalidArgument)
else size within limit
ManagedProjection->>Stream: WriteEvents(ProjectionUpdated)
ManagedProjection-->>ProjectionManagement: Updated
ProjectionManagement-->>Client: success
end
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/EventStore.Projections.Core.Tests/Services/projections_manager/when_updating_a_projection_with_oversized_definition.cs (1)
18-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicated setup across both oversized-definition test files.
Given(), the_oversizedQueryfield, and the faulted-status test are identical towhen_posting_a_projection_with_oversized_definition.cs. Consider extracting a shared base fixture for the common setup/assertions to avoid drift between the two scenarios.🤖 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 `@src/EventStore.Projections.Core.Tests/Services/projections_manager/when_updating_a_projection_with_oversized_definition.cs` around lines 18 - 30, The oversized-definition projection tests duplicate the same setup and assertion logic across this fixture and when_posting_a_projection_with_oversized_definition, so extract the shared Given(), _oversizedQuery, and faulted-status assertion into a common base fixture or shared helper. Move the repeated projection setup around when_updating_a_projection_with_oversized_definition and its sibling into a reusable base class, then let each test class keep only the scenario-specific action while inheriting the common assertions.
🤖 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.
Inline comments:
In `@src/EventStore.Projections.Core/Services/Management/ManagedProjection.cs`:
- Around line 895-906: The oversized persisted-state write path in
FailPersistedStateWrite only faults ManagedProjection and leaves an already
running core projection alive. Update this method to call
DisposeCoreProjection() when Created is true, before or alongside Fault(reason),
so a Created/Prepared projection is actually torn down when the management layer
marks it faulted. Keep the existing reply envelope handling unchanged.
---
Nitpick comments:
In
`@src/EventStore.Projections.Core.Tests/Services/projections_manager/when_updating_a_projection_with_oversized_definition.cs`:
- Around line 18-30: The oversized-definition projection tests duplicate the
same setup and assertion logic across this fixture and
when_posting_a_projection_with_oversized_definition, so extract the shared
Given(), _oversizedQuery, and faulted-status assertion into a common base
fixture or shared helper. Move the repeated projection setup around
when_updating_a_projection_with_oversized_definition and its sibling into a
reusable base class, then let each test class keep only the scenario-specific
action while inheriting the common assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cc0ff9a0-637b-470c-b18d-d4d6da1ecb5d
📒 Files selected for processing (12)
src/EventStore.Projections.Core.Tests/Services/projections_manager/when_posting_a_projection_with_oversized_definition.cssrc/EventStore.Projections.Core.Tests/Services/projections_manager/when_updating_a_projection_with_oversized_definition.cssrc/EventStore.Projections.Core/Messages/ProjectionManagementMessage.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.Abort.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.Create.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.Delete.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.Disable.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.Enable.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.Reset.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.Update.cssrc/EventStore.Projections.Core/Services/Grpc/ProjectionManagement.cssrc/EventStore.Projections.Core/Services/Management/ManagedProjection.cs
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
68e6848 to
75b79a7
Compare