{"record":{"id":"1e6bb129ad027ca7","repo":"microsoft/aspire","slug":"unsupported-entrypoint-type-entrypointannotation-type","errorCode":null,"errorMessage":"Unsupported entrypoint type: {entrypointAnnotation.Type}","messagePattern":"Unsupported entrypoint type: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs","lineNumber":887,"sourceCode":"        // Use the provided path verbatim - resolve relative paths against the app working directory\n        var resolvedPath = Path.IsPathRooted(virtualEnvironmentPath)\n            ? virtualEnvironmentPath\n            : Path.GetFullPath(virtualEnvironmentPath, builder.Resource.WorkingDirectory);\n\n        var virtualEnvironment = new VirtualEnvironment(resolvedPath);\n\n        // Get the entrypoint annotation to determine how to update the command\n        if (!builder.Resource.TryGetLastAnnotation<PythonEntrypointAnnotation>(out var entrypointAnnotation))\n        {\n            throw new InvalidOperationException(\"Cannot update virtual environment: Python entrypoint annotation not found.\");\n        }\n\n        // Update the command based on entrypoint type\n        string command = entrypointAnnotation.Type switch\n        {\n            EntrypointType.Executable => virtualEnvironment.GetExecutable(entrypointAnnotation.Entrypoint),\n            EntrypointType.Script or EntrypointType.Module => virtualEnvironment.GetExecutable(\"python\"),\n            _ => throw new InvalidOperationException($\"Unsupported entrypoint type: {entrypointAnnotation.Type}\")\n        };\n\n        builder.WithCommand(command);\n        builder.WithPythonEnvironment(env =>\n        {\n            env.VirtualEnvironment = virtualEnvironment;\n            env.CreateVenvIfNotExists = createIfNotExists;\n        });\n\n        // If createIfNotExists is false, remove venv creator\n        if (!createIfNotExists)\n        {\n            RemoveVenvCreator(builder);\n        }\n\n        return builder;\n    }\n","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs#L869-L905","documentation":"WithVirtualEnvironment maps the stored PythonEntrypointAnnotation.Type to a command via a switch expression. If the annotation carries a Type value outside EntrypointType.Executable/Script/Module, the exhaustive switch falls to the default arm and throws InvalidOperationException.","triggerScenarios":"A PythonEntrypointAnnotation with a newly added or manually assigned EntrypointType value not covered by the switch on the resource when WithVirtualEnvironment runs.","commonSituations":"Library version mismatch where newer EntrypointType members exist; manually constructing PythonEntrypointAnnotation with an unhandled type; future enum additions processed by an older hosting package.","solutions":["Use only documented EntrypointType values (Executable, Script, Module) in your annotation.","Align the Aspire.Hosting.Python package version across the solution so enum and switch logic match.","If you set the annotation manually, switch to Script/Module/Executable as appropriate.","Upgrade the hosting package if the enum value comes from a newer API surface."],"exampleFix":"// before\nnew PythonEntrypointAnnotation { Type = (EntrypointType)99 }\n// after\nnew PythonEntrypointAnnotation { Type = EntrypointType.Script }","handlingStrategy":"validation","validationCode":"if (resource.TryGetLastAnnotation<PythonEntrypointAnnotation>(out var ann) &&\n    ann.Type is not (EntrypointType.Executable or EntrypointType.Script or EntrypointType.Module))\n    throw new InvalidOperationException($\"Unsupported EntrypointType: {ann.Type}\");","typeGuard":"static bool IsKnownEntrypointType(EntrypointType t) => t is EntrypointType.Executable or EntrypointType.Script or EntrypointType.Module;","tryCatchPattern":"try\n{\n    pyApp.WithVirtualEnvironment(\".venv\");\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Unsupported entrypoint type\"))\n{\n    logger.LogError(ex, \"Entrypoint annotation carries an unsupported EntrypointType.\");\n}","preventionTips":["Only use documented EntrypointType members.","Keep Aspire.Hosting.Python package versions aligned across projects.","Never hand-craft PythonEntrypointAnnotation with unusual type values."],"tags":["csharp","aspire","python","enum"],"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"}