fix(events): eager-deploy EndDate must be end-of-rotation-day, not midnight#815
Merged
Merged
Conversation
mainElement.EndDate was set to rotationDate (00:00 UTC). The downstream guard `if (mainElement.EndDate > DateTime.UtcNow)` then silently skipped _sdkCore.CaseCreate for any today-rotation deploy that ran after 00:00 UTC, leaving Compliance rows with MicrotingSdkCaseId=0. Now uses rotationDate.AddDays(1).AddTicks(-1) so the SDK case is created on any same-day deploy. Adds a regression test that pins the contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Rename today-rotation test to AdmittedByCandidateFilter; previous name oversold a tautology (the assertion fires at planning-lookup, not at the EndDate guard the fix touched). - Update stale comment at EventDeployService.cs:325-328 — the new end-of-day EndDate value satisfies the guard; the candidate filter is no longer the mechanism. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Companion fix to PR #813. The eager-deploy path set mainElement.EndDate = rotationDate (midnight UTC), so the downstream guard if (mainElement.EndDate > DateTime.UtcNow) skipped CaseCreate for any same-day deploy fired after 00:00 UTC, leaving Compliance rows with MicrotingSdkCaseId=0. The fix shifts EndDate to end-of-rotation-day UTC so the guard passes throughout the rotation day, and adds a regression test pinning that today's rotations are admitted by the candidate filter.
Changes:
- Set
mainElement.EndDate = rotationDate.AddDays(1).AddTicks(-1)and update surrounding comments to document the rationale. - Add integration test
EnsureDeployedAsync_TodayRotation_AdmittedByCandidateFilterthat verifies a today-dated rotation reaches the planning-lookup step.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/EventDeployService/EventDeployService.cs | Use end-of-rotation-day UTC for mainElement.EndDate so the same-day deploy guard passes. |
| eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn.Integration.Test/EventDeployServiceTest.cs | Adds regression test pinning that the candidate filter admits today's rotation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Companion fix to PR #813 (eager-deploy of future events). When
EnsureDeployedAsyncran on a TODAY rotation, the SDK case was never created because of a stalemainElement.EndDatevalue:mainElement.EndDate = rotationDate(parsed as midnight UTC)if (mainElement.EndDate > DateTime.UtcNow)skips CaseCreate_sdkCore.CaseCreateis silently skippedMicrotingSdkCaseId=0(from the unmodifiedplanningCaseSite.MicrotingSdkCaseId)UploadPhoto/CompleteEventfor these rotations fail withFailedPreconditionFix: use
rotationDate.AddDays(1).AddTicks(-1)(end-of-rotation-day UTC) so the guard passes any time the deploy fires within the rotation day.Why this slipped past PR #814's tests
PR #814's 5 tests covered: empty window, past rotation, IsFromCompliance filter, idempotence guard, cancellation. None drove a today rotation through to the EndDate guard, because doing so cleanly requires the full Planning+AreaRulePlanning+Area+Property+eForm graph that we deferred (the SKIPPED tests #5/#6/#8 in the test file).
Regression test included
EnsureDeployedAsync_TodayRotation_AdmittedByCandidateFilter— pins that today's rotation is admitted by the candidate filter at line 131 (rotationDate >= todayUtc). A future refactor that accidentally narrowed this to> todayUtcwould silently exclude today's rotations again. The test comment is honest about what it does and doesn't cover (doesn't directly exercise the EndDate guard — that needs the full graph).Verification
7031c567renamed to be honest about what's pinned vs deferred.dotnet buildclean (0 errors).Also worth knowing: two existing Compliance rows in the local DB (
420_eform-backend-configuration-plugin.CompliancesIDs 10219 + 10222) haveMicrotingSdkCaseId=0from before the fix. They need to be soft-deleted (WorkflowState='Removed') so the next eager deploy creates them properly. That's a runtime data-cleanup task, not part of this code change.🤖 Generated with Claude Code