Skip to content

fix(binding-tcp): enforce per-route exit requirement for kind: server - #2241

Merged
jfallows merged 2 commits into
developfrom
claude/github-issue-2239-fncr45
Jul 31, 2026
Merged

jfallows merged 2 commits into
developfrom
claude/github-issue-2239-fncr45

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Description

binding-tcp's schema patch requires kind: server to declare exit either top-level or per-route, via an anyOf with two branches. The per-route branch checked "routes": { "required": ["exit"] }, but per JSON Schema semantics required only constrains object instances — routes is a type: array, so the check was vacuously true against any array and never actually inspected route contents.

Net effect: a kind: server binding with routes: and no exit anywhere (top-level or per-route) passed schema validation, when it should be rejected. Such a route resolves to route.id = 0 at engine-attach time (EngineManager.NameResolver.resolve returns 0L for a null name), silently breaking routing instead of failing at startup with a clear error.

Fix: wrap the per-route check in items so it actually reaches each route object: "routes": { "items": { "required": ["exit"] } }.

Added SchemaTest fixtures:

  • server.routes.exit.yaml — routes with per-route exit, no top-level exit — confirms the intended valid case still passes.
  • server.routes.exit.missing.invalid.yaml — routes with no exit anywhere — confirms it is now rejected. Verified this test fails for the right reason against the pre-fix schema.

Fixes #2239

Test plan

  • ./mvnw -pl specs/binding-tcp.spec test -Dtest=SchemaTest — all 15 cases pass
  • Confirmed the new negative test fails against the pre-fix schema (reverted the schema change locally, re-ran, saw the expected JsonException was not thrown)
  • ./mvnw -pl specs/binding-tcp.spec license:check checkstyle:check passes

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits July 31, 2026 15:07
The anyOf branch intended to allow routes[].exit as an alternative to
top-level exit only checked "required": ["exit"] directly against the
routes array, which is vacuously true for any array instance. Wrap it
in "items" so the check actually reaches each route object, rejecting
a kind: server binding whose routes have no exit anywhere.

Fixes #2239
An empty routes array satisfied the per-route exit check vacuously
(items has nothing to iterate), so kind: server with routes: [] and
no top-level exit still passed schema validation despite providing
no usable exit at all. Add minItems: 1 to close this gap.

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up commit: added minItems: 1 to the per-route exit branch. Without it, routes: [] (empty array) with no top-level exit still passed vacuously, since items has nothing to iterate over an empty array. Now the requirement is exactly: top-level exit, OR routes with at least one item and exit on every item. New SchemaTest case (server.routes.empty.invalid.yaml) confirms this is now rejected, and I verified it fails without minItems first.


Generated by Claude Code

@jfallows
jfallows merged commit 5d8b31f into develop Jul 31, 2026
42 checks passed
jfallows pushed a commit that referenced this pull request Jul 31, 2026
…t/proxy kind

Now that binding-mcp-http supports kind: client (implicit sys:http_client
exit via zilla.binding.mcp.http.client.exit, #2243), the generated
mcp_http0 no longer needs to always be kind: proxy defaulting to a
JVM-wide httpClientExit Configuration property owned by mcp_openapi
itself. McpOpenapiCompositeGenerator now mirrors kind: proxy when a
resolved exit exists (whether authored directly or passed through by a
generator like binding-mcp-schema-registry), kind: client otherwise,
relying entirely on mcp-http's own default. Removes the now-redundant
zilla.binding.mcp.openapi.http.client.exit Configuration property.

McpOpenapiClientIT and McpSchemaRegistryClientIT switch their exit
override to zilla.binding.mcp.http.client.exit (owned by mcp-http)
since there is no longer an mcp-openapi-level exit for kind: client.

Also updates the mcp_openapi schema patch's kind: proxy per-route exit
requirement to match binding-mcp-http's actual if/with-then/exit shape
(and binding-tcp's now-fixed #2241 items-based enforcement) rather than
the vacuous array-level "required" this mirrored initially.

Rebased onto latest develop (#2241, #2243, #2244).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SgdvrgkrnhEy7uUpoan62L
jfallows added a commit that referenced this pull request Jul 31, 2026
…xit (#2242)

* feat(binding-mcp-openapi): add kind: proxy variant with operator-declared exit

Widens mcp_openapi's kind enum to [client, proxy]. kind: proxy requires
exit (top-level or per-route, mirroring binding-tcp's kind: server
pattern, written to actually enforce per-route via "contains" rather
than tcp's vacuous array-typed "required"); kind: client keeps
disallowing exit.

McpOpenapiBindingConfig now resolves a binding-level exit from the
engine's own pre-resolved route.id (set generically by EngineManager
for every route before binding-specific code runs) rather than
re-resolving the raw route.exit string, and McpOpenapiCompositeGenerator
prefers it over the configured httpClientExit default when stamping
mcp_http0's routes. McpOpenapiBinding/McpOpenapiBindingContext widen
their kind == CLIENT gates to also accept PROXY, mirroring the
client+proxy dual-kind pattern binding-mcp-schema-registry uses for its
own kind: proxy variant.

Adds McpOpenapiProxyIT (reusing the existing mcp/http .rpt scripts
against a kind: proxy + exit fixture) and SchemaTest coverage for the
valid/invalid kind/exit combinations.

Fixes #2237

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SgdvrgkrnhEy7uUpoan62L

* refactor(binding-mcp-openapi): generate mcp_http0 with matching client/proxy kind

Now that binding-mcp-http supports kind: client (implicit sys:http_client
exit via zilla.binding.mcp.http.client.exit, #2243), the generated
mcp_http0 no longer needs to always be kind: proxy defaulting to a
JVM-wide httpClientExit Configuration property owned by mcp_openapi
itself. McpOpenapiCompositeGenerator now mirrors kind: proxy when a
resolved exit exists (whether authored directly or passed through by a
generator like binding-mcp-schema-registry), kind: client otherwise,
relying entirely on mcp-http's own default. Removes the now-redundant
zilla.binding.mcp.openapi.http.client.exit Configuration property.

McpOpenapiClientIT and McpSchemaRegistryClientIT switch their exit
override to zilla.binding.mcp.http.client.exit (owned by mcp-http)
since there is no longer an mcp-openapi-level exit for kind: client.

Also updates the mcp_openapi schema patch's kind: proxy per-route exit
requirement to match binding-mcp-http's actual if/with-then/exit shape
(and binding-tcp's now-fixed #2241 items-based enforcement) rather than
the vacuous array-level "required" this mirrored initially.

Rebased onto latest develop (#2241, #2243, #2244).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SgdvrgkrnhEy7uUpoan62L

* refactor(binding-mcp-openapi): propagate own kind onto generated mcp_http0 directly

Replace the derived binding.exit != null ? PROXY : CLIENT check with a
direct .kind(binding.kind) propagation. client (no exit anywhere) and
proxy (exit required) now have a precisely-specified meaning enforced
by the schema, and every caller of McpOpenapiBindingConfig lives in
this codebase — so trust the kind a caller sets rather than deriving it
defensively from exit presence. A caller that sets kind and exit
inconsistently (e.g. kind: client with an exit stamped on a route) will
now simply not route correctly, which is the right failure mode: it
gets caught by tests and fixed at the source, rather than silently
papered over here.

Updates the one unit test exercising this path to author its binding
as kind: proxy (the real, schema-valid way to declare an exit) instead
of kind: client + exit (a caller-side inconsistency this no longer
special-cases).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SgdvrgkrnhEy7uUpoan62L

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants