diff --git a/src/Concelier/StellaOps.Concelier.WebService/Extensions/TopologySetupEndpointExtensions.cs b/src/Concelier/StellaOps.Concelier.WebService/Extensions/TopologySetupEndpointExtensions.cs index 7d2ec1a92..4010893f3 100644 --- a/src/Concelier/StellaOps.Concelier.WebService/Extensions/TopologySetupEndpointExtensions.cs +++ b/src/Concelier/StellaOps.Concelier.WebService/Extensions/TopologySetupEndpointExtensions.cs @@ -5,6 +5,7 @@ using StellaOps.ReleaseOrchestrator.Environment.InfrastructureBinding; using StellaOps.ReleaseOrchestrator.Environment.Readiness; using StellaOps.ReleaseOrchestrator.Environment.Region; using StellaOps.ReleaseOrchestrator.Environment.Rename; +using StellaOps.ReleaseOrchestrator.Environment.Services; using EnvModels = StellaOps.ReleaseOrchestrator.Environment.Models; namespace StellaOps.Concelier.WebService.Extensions; @@ -365,12 +366,37 @@ internal static class TopologySetupEndpointExtensions var envs = app.MapGroup("/api/v1/environments") .WithTags("Topology Readiness"); - envs.MapGet("/{id:guid}/readiness", async ( - Guid id, + // Accept GUID or environment name (e.g. "dev", "stage", "prod-us-east"). + // Returns an empty list when the environment has no targets registered yet. + envs.MapGet("/{id}/readiness", async ( + string id, [FromServices] ITopologyReadinessService readinessService, + [FromServices] IEnvironmentService environmentService, CancellationToken ct) => { - var reports = await readinessService.ListByEnvironmentAsync(id, ct); + Guid? environmentId = null; + if (Guid.TryParse(id, out var parsed)) + { + environmentId = parsed; + } + else + { + var env = await environmentService.GetByNameAsync(id, ct); + if (env is not null) + environmentId = env.Id; + } + + // Environment not yet registered in orchestrator → empty readiness (not an error) + if (environmentId is null) + { + return HttpResults.Ok(new ReadinessListResponse + { + Items = [], + TotalCount = 0 + }); + } + + var reports = await readinessService.ListByEnvironmentAsync(environmentId.Value, ct); return HttpResults.Ok(new ReadinessListResponse { Items = reports.Select(MapReport).ToList(),