Propagate Status and Error in typed handler model mapping#374
Merged
Conversation
TypedResourceOperationHandler dropped the Resource Status/Error fields (and ResourcePreview Status) when mapping between strongly-typed and untyped contract models. This silently broke the RELO (resource-based long-running operation) flow for typed handlers: a status/error set on the typed result never reached the untyped response, so the host never observed it. Fix ToResource/ToTypedResource to copy Status and Error, and ToResourcePreview/ToTypedResourcePreview to copy Status (ResourcePreview has no Error). Add an AspNetCore.Tests.Unit project with regression tests covering create/get/delete/preview mapping.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #374 +/- ##
==========================================
+ Coverage 45.04% 52.27% +7.23%
==========================================
Files 108 108
Lines 2100 2106 +6
Branches 235 235
==========================================
+ Hits 946 1101 +155
+ Misses 1111 954 -157
- Partials 43 51 +8
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in the typed handler model mappers so RELO (resource-based long-running operations) can correctly propagate Resource.Status / Resource.Error (and ResourcePreview.Status) between strongly-typed handler models and the untyped V2 contract models.
Changes:
- Propagate
StatusandErrorinToResource/ToTypedResourcemappings. - Propagate
StatusinToResourcePreview/ToTypedResourcePreviewmappings. - Add a new unit test project with regression tests covering create/get/delete/preview round-trips via the public handler interfaces.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/Azure.Deployments.Extensibility.AspNetCore/Handlers/TypedResourceOperationHandler.cs | Adds Status/Error propagation to typed/untyped resource mapping helpers. |
| src/Azure.Deployments.Extensibility.AspNetCore.Tests.Unit/Handlers/TypedResourceMappingTests.cs | Adds regression tests ensuring Status/Error survive typed↔untyped mapping via handler interfaces. |
| src/Azure.Deployments.Extensibility.AspNetCore.Tests.Unit/Azure.Deployments.Extensibility.AspNetCore.Tests.Unit.csproj | Introduces new unit test project for AspNetCore typed mapping tests. |
| Azure.Deployments.Extensibility.sln | Adds the new unit test project to the solution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Only set Error alongside a Failed status in mapping tests (the V2 contract requires error only when status is Failed); split create into non-terminal and failed cases and add untyped-to-typed (ToTypedResource/ToTypedResourcePreview) coverage. - Add [assembly: AssemblyTrait(Category, Unit)] so the CI 'Category=Unit' filter runs these tests (fixes 0% patch coverage). - Use the SDK-style project type GUID for the new test project in the solution.
majastrz
approved these changes
Jun 24, 2026
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
TypedResourceOperationHandlerdropped theResource.Status/Resource.Errorfields (andResourcePreview.Status) when mapping between the strongly-typed handler models and the untyped V2 contract models.This silently broke the RELO (resource-based long-running operation) flow for any handler built on the typed base classes: a non-terminal status (e.g.
"Running") or a terminal"Failed"+errorset on the typed result never reached the untyped response. Because Get/Delete also funnel throughToResource(viaToNullableResource), polling never observed the status, so RELO appeared to complete synchronously.LRO was unaffected, since
LongRunningOperationis returned via passthrough rather than through these mappers.Changes
ToResource(typed → untyped) andToTypedResource(untyped → typed): copyStatusandError.ToResourcePreviewandToTypedResourcePreview: copyStatus(ResourcePreviewhas noErrorfield).Azure.Deployments.Extensibility.AspNetCore.Tests.Unitwith regression tests driving real typed handlers through the public interface and assertingStatus/Errorsurvive the round trip (create, get, delete, preview). These fail on the previous code and pass now.Testing
Rollback
Revert this commit. The change only adds field assignments in the model-mapping helpers, so reverting restores the prior behavior with no migration or state concerns.