{"record":{"id":"da281ff2bfae666d","repo":"microsoft/aspire","slug":"error-converting-resource-name-to-resourceviewmodel","errorCode":null,"errorMessage":"Error converting resource \"{Name}\" to ResourceViewModel.","messagePattern":"Error converting resource \"(.+?)\" to ResourceViewModel\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Dashboard/ServiceClient/Partials.cs","lineNumber":53,"sourceCode":"                Properties = CreatePropertyViewModels(resourceType, Properties, knownPropertyLookup, logger),\n                Environment = GetEnvironment(),\n                Urls = GetUrls(),\n                Volumes = GetVolumes(),\n                Relationships = GetRelationships(),\n                State = HasState ? State : null,\n                KnownState = HasState ? Enum.TryParse(State, out KnownResourceState knownState) ? knownState : null : null,\n                StateStyle = HasStateStyle ? StateStyle : null,\n                Commands = GetCommands(),\n                HealthReports = HealthReports.Select(ToHealthReportViewModel).OrderBy(vm => vm.Name).ToImmutableArray(),\n                IsHidden = IsHidden,\n                SupportsDetailedTelemetry = SupportsDetailedTelemetry,\n                IconName = HasIconName ? IconName : null,\n                IconVariant = HasIconVariant ? MapResourceIconVariant(IconVariant) : null\n            };\n        }\n        catch (Exception ex)\n        {\n            throw new InvalidOperationException($@\"Error converting resource \"\"{Name}\"\" to {nameof(ResourceViewModel)}.\", ex);\n        }\n\n        HealthReportViewModel ToHealthReportViewModel(HealthReport healthReport)\n        {\n            return new HealthReportViewModel(\n                healthReport.Key, \n                healthReport.HasStatus ? MapHealthStatus(healthReport.Status) : null, \n                healthReport.Description, \n                healthReport.Exception)\n            {\n                LastRunAtTimeStamp = healthReport.LastRunAt?.ToDateTime()\n            };\n        }\n\n        Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus MapHealthStatus(HealthStatus healthStatus)\n        {\n            return healthStatus switch\n            {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Dashboard/ServiceClient/Partials.cs#L35-L71","documentation":"This error wraps any exception thrown while converting a gRPC Resource protobuf message into a dashboard ResourceViewModel. The real cause is available as the InnerException; the outer message only tells you which resource failed. It exists so the dashboard can attribute conversion failures to a specific named resource.","triggerScenarios":"Any property access or mapping inside the ToViewModel conversion throws — e.g. malformed resource data from the server, unexpected enum values for icons/variants, or null/invalid fields in the Resource snapshot sent by the AppHost.","commonSituations":"A newer AppHost sends resource data the dashboard version does not understand (version skew), a resource reports unusual metadata (unknown icon name/variant), or corrupted/partial protobuf state arrives during a dashboard session.","solutions":["Inspect the InnerException stack trace to find the exact failing property","Ensure dashboard and AppHost/CLI/SDK versions match (upgrade both together)","Restart the AppHost so the dashboard receives a clean resource snapshot","Report the inner exception to Aspire if it occurs with matched versions"],"exampleFix":"// before: opaque failure\nvar vm = resource.ToViewModel();\n// after: log the inner cause\ntry\n{\n    var vm = resource.ToViewModel();\n}\ncatch (InvalidOperationException ex)\n{\n    logger.LogError(ex.InnerException, \"Failed to convert resource {Name}\", resource.Name);\n}","handlingStrategy":"try-catch","validationCode":"if (resource is null || string.IsNullOrEmpty(resource.Name))\n{\n    throw new ArgumentException(\"Resource and Name must be populated before conversion\");\n}","typeGuard":null,"tryCatchPattern":"try { var vm = resource.ToViewModel(); }\ncatch (InvalidOperationException ex)\n{\n    logger.LogError(ex.InnerException, \"Conversion failed for resource {Name}\", resource.Name);\n}","preventionTips":["Keep dashboard and AppHost/SDK versions matched","Inspect InnerException for the real cause before retrying","Report persistent inner failures to Aspire with the resource payload"],"tags":["dashboard","grpc","conversion","version-skew"],"backgroundTag":"type-mismatch","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}