fix(mesh): reject opt-in when every service has empty ports (#1056)

optInStack rejected empty service lists but not the case where services
exist with every ports: []. The newPorts Set ended up empty, the
function sailed past collision checks, wrote a mesh_stacks row, and
produced an empty-aliases override. The stack then appeared online in
the Routing tab but no traffic actually routed.

Add a check after building newPorts: throw no_target with a clear
message before the SENCHO_LISTEN_PORT collision check. Reuses the
existing MeshError code (semantically: no routable target) so the
frontend's error toast path is unchanged.
This commit is contained in:
Anso
2026-05-15 09:00:24 -04:00
committed by GitHub
parent 6185206323
commit 3d5f0ffacd
2 changed files with 26 additions and 0 deletions
+6
View File
@@ -565,6 +565,12 @@ export class MeshService extends EventEmitter implements MeshForwarderHost {
const newPorts = new Set<number>();
for (const svc of services) for (const p of svc.ports) newPorts.add(p);
if (newPorts.size === 0) {
throw new MeshError(
'no_target',
`stack ${stackName} has no service ports to mesh (every service declared ports: [])`,
);
}
if (newPorts.has(SENCHO_LISTEN_PORT)) {
throw new MeshError(
'port_collision',