Skip to content

Use display name without DCP suffix in resource command error messages#16148

Merged
JamesNK merged 2 commits intomainfrom
jamesnk/resource-command-display-name
Apr 15, 2026
Merged

Use display name without DCP suffix in resource command error messages#16148
JamesNK merged 2 commits intomainfrom
jamesnk/resource-command-display-name

Conversation

@JamesNK
Copy link
Copy Markdown
Member

@JamesNK JamesNK commented Apr 14, 2026

Description

Resource command error messages previously included the full DCP resource ID (e.g., cache-abcdwxyz) even for single-instance resources. This is confusing because users know the resource by its display name (cache).

This PR:

  • Adds GetResolvedDisplayResourceName extension method on IResource that returns the display name for single-instance resources and the full DCP resource ID for resources with replicas.
  • Uses it in ResourceCommandService.ExecuteCommandCoreAsync for the "command not available" error message.
  • Renames the existing private helper in CommandsConfigurationExtensions to GetResolvedDcpResouceName to distinguish it from the new method.
  • Adds two tests verifying the error message format for both single-instance and replica scenarios.

Before:
image

After:
image

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Copilot AI review requested due to automatic review settings April 14, 2026 14:24
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16148

Or

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

Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates resource command error messages to use the resource’s display name for single-instance resources, while keeping full DCP resource IDs for replica scenarios to avoid ambiguity.

Changes:

  • Added IResource.GetResolvedDisplayResourceName(resourceId) to choose display name vs. full resource ID based on replica count.
  • Updated ResourceCommandService.ExecuteCommandCoreAsync to use the resolved display name in the “command not available” error message.
  • Renamed an existing helper method in CommandsConfigurationExtensions and added tests for single-instance vs replica message formatting.

Reviewed changes

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

File Description
tests/Aspire.Hosting.Tests/ResourceCommandServiceTests.cs Adds tests asserting error message formatting for single-instance vs replica resources.
src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs Introduces GetResolvedDisplayResourceName utility for display name vs instance ID selection.
src/Aspire.Hosting/ApplicationModel/ResourceCommandService.cs Switches the “command not available” message to use the resolved display/instance name.
src/Aspire.Hosting/ApplicationModel/CommandsConfigurationExtensions.cs Renames helper used in lifecycle command success messages to distinguish from the new extension method.

@JamesNK JamesNK added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@JamesNK JamesNK enabled auto-merge (squash) April 15, 2026 07:53
JamesNK added 2 commits April 15, 2026 15:58
Add GetResolvedDisplayResourceName extension method to return the
resource display name for single-instance resources and the full DCP
resource ID for resources with replicas. Use it in ResourceCommandService
error messages and rename the existing helper in
CommandsConfigurationExtensions to GetResolvedDcpResouceName.
@JamesNK JamesNK force-pushed the jamesnk/resource-command-display-name branch from 59e78c0 to bee48dd Compare April 15, 2026 07:59
@JamesNK JamesNK merged commit 3f259d5 into main Apr 15, 2026
550 of 553 checks passed
@github-actions github-actions bot added this to the 13.3 milestone Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 69 recordings uploaded (commit bee48dd)

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
Banner_NotDisplayedWithNoLogoFlag ▶️ 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
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ 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
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24443212932

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

No documentation PR is required for this change.

This is a bug fix to error message formatting — replacing the internal DCP resource ID suffix (e.g., cache-abcdwxyz) with the user-friendly display name (e.g., cache) in resource command error messages. It involves no new public APIs, no new features, no configuration changes, and no behavioral changes that would need to be documented.

Generated by PR Documentation Check for issue #16148 · ● 201.3K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants