Repository navigation
Description
Summary
binding-tcp's schema patch (specs/binding-tcp.spec/.../schema/tcp.schema.patch.json) requires kind: server to declare exit either top-level or per-route:
{
"properties": { "kind": { "const": "server" } },
"anyOf":
[
{ "required": [ "exit" ] },
{
"properties": { "routes": { "required": [ "exit" ] } },
"required": [ "routes" ]
}
]
}The second anyOf branch — the per-route alternative — looks like it doesn't actually enforce anything. "required" only constrains object instances (per JSON Schema semantics, object-only keywords like required/properties/additionalProperties/patternProperties are vacuously satisfied against instances of any other type). routes is declared "type": "array" elsewhere in the same schema, so "routes": { "required": [ "exit" ] } } is checking required: ["exit"] against an array instance, which trivially passes regardless of content. It needed an "items" wrapper to actually reach each route object: "routes": { "items": { "required": [ "exit" ] } } }.
Net effect: only the top-level "required": ["exit"] branch does real work. A kind: server binding that declares routes: with per-route exit: on each item, but no top-level exit:, should be valid (that's clearly the intent — the whole point of the anyOf is to allow either style) — but a kind: server binding with routes: and no exit anywhere (top-level or per-route) also currently passes schema validation, when it should be rejected. Any route lacking a resolvable exit string will resolve to route.id = 0 at engine-attach time (EngineManager.NameResolver.resolve returns 0L for a null name, no error) — silently broken routing instead of a clear startup validation error.
Repro / how to confirm
Add a SchemaTest fixture: kind: server with routes: [{ when: [...] }] (no exit anywhere, top-level or per-route) and assert it's currently accepted (it shouldn't be). Also confirm the intended valid case — routes with per-route exit: and no top-level exit: — is separately still accepted after the fix (it already is today, coincidentally, since the broken branch's vacuous truth means the anyOf always succeeds via that branch; after fixing the nesting, it needs to keep succeeding via a real check that each route actually has exit).
Suggested fix
{
"properties": { "routes": { "items": { "required": [ "exit" ] } } },
"required": [ "routes" ]
}Context
Found incidentally while designing binding-mcp-http's own analogous kind: proxy exit requirement (#2238), which was going to mirror this exact pattern — flagging here instead of silently copying the same mistake. Not fixing as part of #2238; this is binding-tcp's own pre-existing schema, independent of the mcp-http work.
Activity
fix(binding-tcp): enforce per-route exit requirement for kind: server (…