{"record":{"id":"88a193b4d9c9566e","repo":"microsoft/aspire","slug":"unexpected-wait-type-waitannotation-waittype","errorCode":null,"errorMessage":"Unexpected wait type: {waitAnnotation.WaitType}","messagePattern":"Unexpected wait type: (.+?)","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs","lineNumber":558,"sourceCode":"                    }\n                    else\n                    {\n                        await ClearWaitingForDependenciesAsync(resource).ConfigureAwait(false);\n                    }\n                }\n                finally\n                {\n                    pendingDependencyLock.Release();\n                }\n            }\n\n            var pendingDependencies = waitAnnotationsToProcess\n                .Select(waitAnnotation => waitAnnotation.WaitType switch\n                {\n                    WaitType.WaitUntilHealthy => WaitUntilHealthyAsync(resource, waitAnnotation.Resource, waitAnnotation.WaitBehavior ?? DefaultWaitBehavior, cancellationToken, OnDependencyReadyAsync),\n                    WaitType.WaitForCompletion => WaitUntilCompletionAsync(resource, waitAnnotation.Resource, waitAnnotation.ExitCode, cancellationToken, OnDependencyReadyAsync),\n                    WaitType.WaitUntilStarted => WaitUntilStartedAsync(resource, waitAnnotation.Resource, waitAnnotation.WaitBehavior ?? DefaultWaitBehavior, cancellationToken, OnDependencyReadyAsync),\n                    _ => throw new DistributedApplicationException($\"Unexpected wait type: {waitAnnotation.WaitType}\")\n                });\n\n            await Task.WhenAll(pendingDependencies).ConfigureAwait(false);\n\n            var clearRemainingDependencies = false;\n            await pendingDependencyLock.WaitAsync(CancellationToken.None).ConfigureAwait(false);\n            try\n            {\n                clearRemainingDependencies = pendingDependencyCounts.Count > 0;\n                pendingDependencyCounts.Clear();\n            }\n            finally\n            {\n                pendingDependencyLock.Release();\n            }\n\n            if (clearRemainingDependencies)\n            {","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs#L540-L576","documentation":"Exhaustiveness guard in WaitForDependenciesAsync: a WaitAnnotation had a WaitType other than WaitUntilHealthy, WaitForCompletion, or WaitUntilStarted. The switch throws DistributedApplicationException for the unknown wait type.","triggerScenarios":"Custom code (or a mismatched extension package) constructing a WaitAnnotation with an undefined or unsupported WaitType value, which then flows through WaitForDependenciesAsync during resource start orchestration.","commonSituations":"Casting ints to WaitType in custom resource extensions; Aspire.Hosting version drift where a newer WaitType member is consumed by older hosting code; hand-written annotations copied with wrong enum values.","solutions":["Only construct wait annotations with the three supported WaitType members: WaitUntilHealthy, WaitForCompletion, WaitUntilStarted.","Remove numeric casts/default(WaitType) in custom annotation code.","Align Aspire.Hosting package versions between the AppHost and any custom extension libraries."],"exampleFix":"// before\nvar wait = new WaitAnnotation(dep, (WaitType)99);\n\n// after\nvar wait = new WaitAnnotation(dep, WaitType.WaitUntilStarted);","handlingStrategy":"validation","validationCode":"static bool IsSupportedWaitType(WaitType t) =>\n    t is WaitType.WaitUntilHealthy or WaitType.WaitForCompletion or WaitType.WaitUntilStarted;\nif (!IsSupportedWaitType(annotation.WaitType)) throw new ArgumentException($\"Unsupported WaitType: {annotation.WaitType}\");","typeGuard":"static bool IsDefinedWaitType(WaitType value) =>\n    value is WaitType.WaitUntilHealthy or WaitType.WaitForCompletion or WaitType.WaitUntilStarted;","tryCatchPattern":"try\n{\n    await app.StartAsync();\n}\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"Unexpected wait type\"))\n{\n    logger.LogError(ex, \"Invalid WaitType in a WaitAnnotation.\");\n}","preventionTips":["Construct WaitAnnotation only with the three supported WaitType members.","Remove numeric casts to WaitType from custom extensions.","Version-align Aspire.Hosting with any custom orchestration libraries.","Add tests enumerating all wait annotations in the app model."],"tags":["aspire","enum","wait-type","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-21T09:17:21.228Z"}