Skip to content

Fix serialization issue with enum when building capabilities#14784

Merged
davidfowl merged 3 commits intomicrosoft:mainfrom
IEvangelist:fix-polyglot-serialization
Feb 28, 2026
Merged

Fix serialization issue with enum when building capabilities#14784
davidfowl merged 3 commits intomicrosoft:mainfrom
IEvangelist:fix-polyglot-serialization

Conversation

@IEvangelist
Copy link
Member

Description

Add JsonStringEnumConverter to JSON serialization options in AtsMarshaller and CapabilityDispatcher.

Contributes to #14772

Resolves this following error:

❌ Uncaught Exception: The JSON value could not be converted to System.Nullable`1[[Aspire.Hosting.ApplicationModel.IconVariant]]. Path: $.iconVariant | LineNumber: 0 |        
BytePositionInLine: 54.
CapabilityError: The JSON value could not be converted to System.Nullable`1[[Aspire.Hosting.ApplicationModel.IconVariant]]. Path: $.iconVariant | LineNumber: 0 |
BytePositionInLine: 54.
    at AspireClient.invokeCapability (D:\GitHub\TsApp\.modules\transport.ts:536:23)
    at async PostgresDatabaseResource._withCommandInternal (D:\GitHub\TsApp\.modules\aspire.ts:4648:24)
    at async <anonymous> (D:\GitHub\TsApp\apphost.ts:26:1)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings February 27, 2026 21:16
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14784

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14784"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds JsonStringEnumConverter to the JSON serialization options used by ATS marshalling and capability dispatching to ensure enums can round-trip as strings (fixing enum deserialization failures like iconVariant).

Changes:

  • Add JsonStringEnumConverter to CapabilityDispatcher JSON options for DTO parsing.
  • Add JsonStringEnumConverter to AtsMarshaller JSON options for DTO marshal/unmarshal.
  • Add unit tests covering enum string serialization/deserialization behaviors (including case-insensitive reads).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/Aspire.Hosting.RemoteHost.Tests/CapabilityDispatcherTests.cs Adds GetDto tests validating enum properties deserialize from string values.
tests/Aspire.Hosting.RemoteHost.Tests/AtsMarshallerTests.cs Adds tests asserting enum string converter is present and enums round-trip as strings.
src/Aspire.Hosting.RemoteHost/Ats/CapabilityDispatcher.cs Configures dispatcher JSON options to include JsonStringEnumConverter.
src/Aspire.Hosting.RemoteHost/Ats/AtsMarshaller.cs Configures marshaller JSON options to include JsonStringEnumConverter.

@davidfowl davidfowl merged commit 7819069 into microsoft:main Feb 28, 2026
343 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.3 milestone Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants