From 6e72ad844ed04dfdc4d8e8e4d46210a7059ded51 Mon Sep 17 00:00:00 2001 From: master <> Date: Tue, 7 Apr 2026 15:33:11 +0300 Subject: [PATCH] feat(concelier): accept environment name or GUID in readiness endpoint The /environments/{id}/readiness endpoint now resolves environment names (e.g. "dev", "prod-us-east") via IEnvironmentService, returning an empty list for unregistered environments instead of a 404. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../TopologySetupEndpointExtensions.cs | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) 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(),