Skip to content

Fix Swarm UpdateConfig property types - #15566

Merged
Mitch Denny (mitchdenny) merged 1 commit into
mainfrom
fix/11691-updateconfig-types
Mar 25, 2026
Merged

Mitch Denny (mitchdenny) merged 1 commit into
mainfrom
fix/11691-updateconfig-types

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

Fix incorrect property types in the Docker Swarm UpdateConfig class that cause invalid Docker Compose YAML to be generated.

Two bugs:

  • Parallelism was string? but Docker Compose spec requires an integer. This caused the value to be serialized as "2" (quoted string) instead of 2 (integer), which Docker rejects.
  • FailOnError was bool? mapped to failure_action, but Docker Compose spec requires a string enum ("continue", "rollback", or "pause"). Renamed to FailureAction to better reflect the YAML alias failure_action and its semantics.

Also added a snapshot unit test verifying correct YAML serialization of all UpdateConfig properties.

Fixes #11691

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?

- Change Parallelism from string? to int? (Docker spec requires integer)
- Rename FailOnError to FailureAction and change from bool? to string?
  (Docker spec requires "continue", "rollback", or "pause")
- Update XML documentation for both properties
- Add snapshot test verifying correct YAML serialization

Fixes #11691

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings March 25, 2026 03:00
@github-actions

Copy link
Copy Markdown
Contributor

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15566

Or

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes Docker Swarm deploy.update_config YAML serialization in Aspire’s Docker Compose publisher by correcting mismatched CLR property types so generated Compose files conform to the Docker Compose spec.

Changes:

  • Change UpdateConfig.Parallelism from string? to int? to serialize as a YAML integer.
  • Replace FailOnError (bool?, mapped to failure_action) with FailureAction (string?) to match Compose’s expected string enum.
  • Add a snapshot-based unit test verifying update_config YAML output.

Reviewed changes

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

File Description
src/Aspire.Hosting.Docker/Resources/ServiceNodes/Swarm/UpdateConfig.cs Corrects update_config property types/names to generate valid Swarm Compose YAML.
tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs Adds a verification test covering UpdateConfig serialization.
tests/Aspire.Hosting.Docker.Tests/Snapshots/DockerComposeTests.DockerSwarmUpdateConfigSerializedCorrectly.verified.yaml Adds the expected YAML snapshot including correctly-typed parallelism and failure_action.

Comment on lines 30 to +35
/// <summary>
/// Indicates whether the update process should stop and fail upon encountering an error.
/// Gets or sets the action to take when an update fails.
/// Valid values are <c>"continue"</c>, <c>"rollback"</c>, and <c>"pause"</c>.
/// </summary>
[YamlMember(Alias = "failure_action")]
public bool? FailOnError { get; set; }
public string? FailureAction { get; set; }

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

Renaming FailOnError (bool?) to FailureAction (string?) is a breaking change for consumers. Since the old property also produced invalid Compose YAML, consider keeping an [Obsolete] FailOnError shim (with [YamlIgnore]) that maps true/false to valid failure_action values (e.g., pause vs continue) to provide a smoother migration path while still emitting valid YAML.

Copilot uses AI. Check for mistakes.
Comment on lines 18 to +35
@@ -30,10 +28,11 @@ public sealed class UpdateConfig
public string? Delay { get; set; }

/// <summary>
/// Indicates whether the update process should stop and fail upon encountering an error.
/// Gets or sets the action to take when an update fails.
/// Valid values are <c>"continue"</c>, <c>"rollback"</c>, and <c>"pause"</c>.
/// </summary>
[YamlMember(Alias = "failure_action")]
public bool? FailOnError { get; set; }
public string? FailureAction { get; set; }

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

The checked-in API surface file src/Aspire.Hosting.Docker/api/Aspire.Hosting.Docker.cs still declares UpdateConfig.FailOnError as bool? and UpdateConfig.Parallelism as string?. With this change, the API surface should be updated to reflect FailureAction (string?) and Parallelism (int?), otherwise API-validation/approval tooling is likely to fail or the published API docs will be incorrect.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good assuming that the breaking changing to UpdateConfig are ok.

@github-actions

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 49 recordings uploaded (commit 0f37fa0)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23522799103

@mitchdenny

Copy link
Copy Markdown
Member Author

Yeah its OK because it was completely broken before :)

@mitchdenny
Mitch Denny (mitchdenny) merged commit 8a52612 into main Mar 25, 2026
254 checks passed
@mitchdenny
Mitch Denny (mitchdenny) deleted the fix/11691-updateconfig-types branch March 25, 2026 03:50
Adam Ratzman (adamint) pushed a commit to adamint/aspire that referenced this pull request Mar 28, 2026
)

- Change Parallelism from string? to int? (Docker spec requires integer)
- Rename FailOnError to FailureAction and change from bool? to string?
  (Docker spec requires "continue", "rollback", or "pause")
- Update XML documentation for both properties
- Add snapshot test verifying correct YAML serialization

Fixes microsoft#11691

Co-authored-by: Mitch Denny <[email protected]>
Co-authored-by: Copilot <[email protected]>
/// </summary>
[YamlMember(Alias = "parallelism")]
public string? Parallelism { get; set; }
public int? Parallelism { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just an FYI - this is technically a breaking change since this is public API.

Not a blocker - just wanted to call it out.

@joperezr Jose Perez Rodriguez (joperezr) added this to the 13.3 milestone Apr 14, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Documentation Check ✅

No documentation PR is required for this change.

Reason: This PR fixes incorrect property types in the UpdateConfig class (Parallelism: string? → int?, FailOnError: bool? → FailureAction: string?) to produce valid Docker Compose YAML. While it includes a public API rename (FailOnError → FailureAction), neither UpdateConfig nor Docker Swarm-specific configurations are covered in the existing aspire.dev documentation — so there is no documented behavior to update. This is primarily a bug fix for invalid serialization output.

Generated by PR Documentation Check · ● 224.6K · ◷

@github-actions github-actions Bot locked and limited conversation to collaborators Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swarm Service UpdateConfig serialization errors

5 participants