Repository navigation
Conversation
When two GET requests in one batch resolve to the same key, MergeBatchResultsWithModel merges the second model into the first and marks the duplicate as deleted. Using that duplicate afterwards reported "This model instance was deleted, you can't use it anymore", which sends the caller looking for a delete that never happened. Track that the removal came from the batch consolidation and report that instead, pointing at the instance returned by the first request for that key. The regular delete path keeps its existing message. Fixes pnp#1867
Callers can branch on the consolidation case programmatically instead of having to match on the message. The new member is appended rather than grouped with InstanceWasDeleted because this enum has no explicit values, so inserting in the middle would renumber every member after it.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1922 +/- ##
===========================================
- Coverage 82.42% 62.64% -19.79%
===========================================
Files 416 1296 +880
Lines 28590 108660 +80070
Branches 0 9731 +9731
===========================================
+ Hits 23565 68065 +44500
- Misses 5025 38635 +33610
- Partials 0 1960 +1960 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Follow-up to #1887, implementing option C as agreed in #1867 (comment).
Fixes #1867
The problem
When two GET requests in one batch resolve to the same key,
MergeBatchResultsWithModelmerges the second model into the first and marks the duplicate as deleted. Using that duplicate afterwards reported:Nothing was deleted. The caller goes looking for a delete that never happened, which is what cost the reporter of #1867 the debugging time.
The change
RemoveFromParentCollectionnow records whether the removal came from the batch consolidation, andCheckDeletedreports that case through a dedicatedErrorType.InstanceWasConsolidatedInBatchas you asked for. The regularDelete/RemoveFromModelpath calls the parameterless overload and keeps its existing error type and message.On the breaking change you were willing to accept: it turns out we don't have to take one.
ErrorTypehas no explicit values, so adding the member next toInstanceWasDeletedwould renumber the 14 members after it, which silently shifts the values seen by anything compiled against an older PnP.Core. Appending it instead keeps every existing value stable, so this is purely additive. That is the only reason the new member sits at the bottom of the enum rather than with its relatives, and there is a comment there saying so.Before and after
Two
GetByIdBatchAsynccalls for the same list in one batch, with different projections, then readingTitleoff the second instance. Run against a real tenant.Before:
After:
Tests
Two new tests in
BatchClientTests, offline by design like the existing ones in that region:ConsolidatedInBatchInstanceExplainsItWasConsolidated- the consolidated instance reports the new error type and messageDeletedInstanceStillExplainsItWasDeleted- a genuinely deleted instance keeps the old error type and message, so neither can leak into the delete pathI mutation tested the first one: pointing the consolidation throw back at
ErrorType.InstanceWasDeletedmakes it fail and leaves the second passing.Full offline suite on this branch: 1922 passed, 7 failed, 5 skipped. The 7 are pre-existing failures unrelated to this change (
TimeZoneConversionTests,TimeZoneUtcToLocalTimeTest,TimeZoneUtcToLocalTime2Test,TestSPOAccessToken,TestGraphAccessToken,RepeatedCloneOffLineTest,SchedulePagePublish), none of which touch batching or model state.