{"record":{"id":"2fb7ea2ca1025428","repo":"microsoft/aspire","slug":"unknown-resource-type-resource-gettype-name","errorCode":null,"errorMessage":"Unknown resource type {resource.GetType().Name}","messagePattern":"Unknown resource type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Dcp/DcpExecutor.cs","lineNumber":382,"sourceCode":"                (applicationName[i] is >= 'A' and <= 'Z') ||\n                (applicationName[i] is >= '0' and <= '9') ||\n                (applicationName[i] is '_' or '-' or '.'))\n            {\n                normalizedName.Append(applicationName[i]);\n            }\n        }\n\n        return normalizedName.ToString();\n    }\n\n    internal static string GetResourceType<T>(T resource, IResource appModelResource) where T : CustomResource\n    {\n        return resource switch\n        {\n            Container => KnownResourceTypes.Container,\n            Executable => appModelResource.GetResourceType(),\n            ContainerExec => KnownResourceTypes.ContainerExec,\n            _ => throw new InvalidOperationException($\"Unknown resource type {resource.GetType().Name}\")\n        };\n    }\n\n    Task IDcpObjectFactory.UpdateWithEffectiveAddressInfo(IEnumerable<Service> services, CancellationToken cancellationToken, TimeSpan? timeout)\n        => UpdateWithEffectiveAddressInfo(services, cancellationToken, timeout);\n\n    // Watches DCP object updates via a Kubernetes watch wrapped in the supplied retry pipeline,\n    // till all objects reach desired state or a timeout occurs.\n    // Returns names of objects that did not reach the desired state.\n    private async Task<HashSet<string>> WatchUntilDesiredStateAsync<TDcpResource>(\n        IEnumerable<TDcpResource> objects,\n        Func<TDcpResource, TDcpResource, bool> isInDesiredState,\n        ResiliencePipeline pipeline,\n        CancellationToken cancellationToken)\n        where TDcpResource : CustomResource, IKubernetesStaticMetadata\n    {\n        var objectsByName = new Dictionary<string, TDcpResource>(StringComparer.Ordinal);\n        var pending = new HashSet<string>(StringComparer.Ordinal);","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Dcp/DcpExecutor.cs#L364-L400","documentation":"GetResourceType maps an application-model resource to its DCP kind via a switch over Container/Executable/ContainerExec; any other DCP resource type falls through to an InvalidOperationException. It is an internal completeness guard: the executor encountered a DCP object it does not know how to classify.","triggerScenarios":"DcpExecutor creates DCP objects for a resource whose DCP type is not one of Container, Executable, or ContainerExec (via GetResourceType, backing the resourceType property).","commonSituations":"A custom resource or new DCP object kind introduced without updating DcpExecutor's switch; version skew between Aspire.Hosting assemblies; custom IDcpObjectFactory implementations emitting unsupported types.","solutions":["Update to matching versions of all Aspire.* packages so DCP object kinds align.","If you wrote a custom resource/DCP object, extend the mapping to emit a supported kind (Container, Executable, or ContainerExec).","Check third-party hosting integrations for a newer version supporting your resource type.","Report the resource type name shown in the message to the integration/library maintainer if it comes from a package."],"exampleFix":"// before: custom resource unmapped in DCP projection\nvar dcpObject = new MyCustomDcpType { ... };\n// after: project to a supported DCP kind\nvar dcpObject = new Executable { ... }; // or Container / ContainerExec","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static bool HasSupportedDcpKind(object dcpObject) =>\n    dcpObject is Container or Executable or ContainerExec;","tryCatchPattern":"try\n{\n    var kind = executor.ResourceType(resource);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Unknown resource type\"))\n{\n    logger.LogError(ex, \"Unsupported DCP object for {Resource}; check integration versions.\", resource.Name);\n}","preventionTips":["Keep all Aspire.* packages at identical versions.","When authoring integrations, only emit Container/Executable/ContainerExec DCP objects.","Re-run integration tests after adding new DCP object kinds to catch unhandled switches.","Review custom IDcpObjectFactory implementations for completeness."],"tags":["dcp","resource-type","internal-invariant"],"backgroundTag":"invalid-enum-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}