Skip to content

binding-tcp: kind: server's per-route exit requirement doesn't actually enforce anything #2239

Closed

Description

@jfallows

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

  1. added theissue type on Jul 31, 2026
  2. self-assigned this
    on Jul 31, 2026
  3. added a commit that references this issue on Jul 31, 2026
    5d8b31f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions