Skip to content

fix(binding-asyncapi,binding-openapi,binding-openapi-asyncapi,binding-mcp-openapi): close options.* abstraction leaks and align spec/apiId terminology - #2128

Merged
jfallows merged 27 commits into
developfrom
claude/zilla-issue-2113-plan-8l38nm
Jul 12, 2026

Conversation

@jfallows

@jfallows jfallows commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up to #2079, closing the remaining options.* abstraction leaks it identified in the openapi/asyncapi/openapi-asyncapi/mcp-openapi bindings:

  • Identity resolution: resolveIdentity() used a hardcoded :jwt0 guard reference regardless of which guard security actually resolved. Threads the resolved GuardedRef.qname through to each call site instead; when no guard resolves, {identity} is left unresolved rather than pointing at a guard that likely doesn't exist.
  • mqtt.store: moved from options.mqtt.store to options.specs.<name>.store, since store selection is a per-spec concern, not a per-protocol one.
  • Kafka authorization: options.kafka.authorization is now wired into the generated Kafka client, mirroring the existing http/mqtt authorization pattern, instead of being silently dropped.
  • TLS authority for SNI routing: injectTlsRoutes now populates the generated TLS route condition's authority (from each declared server's hostname), not just port, so SNI-based dispatch works when multiple TLS servers share a port. This is the bounded, unambiguous part of the issue's item 1b — wiring up an existing TlsConditionConfig capability. The broader "one server per distinct-guard group" architecture is deliberately left out: the issue itself flags the guard-group/dispatch design as an open question, and guessing at that shape risks building something that has to be reworked once it's settled.
  • mqttKafka.channels: replaced by an x-zilla-mqtt-kafka AsyncAPI extension declared directly on the Kafka spec's channels (role: sessions|messages|retained), instead of a separate options.mqttKafka.channels block that duplicated channel names the operator could get out of sync with the spec.
  • AsyncAPI Overlay support: extends the OpenAPI Overlay integration landed on develop via feat(common-json,binding-openapi): OpenAPI Overlay Specification support #2130 to asyncapi. An optional options.specs.<name>.overlay reference, shaped like the existing catalog reference, is resolved via the same CatalogHandler and its JsonOverlay actions (from common-json) are applied to the resolved spec payload before AsyncapiParser parses it — mirroring OpenapiCompositeGenerator.materialize() exactly. This lets an operator patch an AsyncAPI spec they can't edit directly (e.g. one fetched from a schema registry).
  • Kafka topic defaults: options.kafka.topics[].defaultOffset/.deltaType were parsed but silently dropped when generating the asyncapi client's Kafka topic config — now wired through, matching the existing transforms handling. Also hardened injectKafkaTopicDefaults against a latent NPE when a matched topic config declares defaults but no transforms.
  • mqtt-kafka channel-role errors: a missing x-zilla-mqtt-kafka role (sessions/messages/retained) on the kafka spec's channels now fails with a clear message naming the extension and the missing role, instead of an unqualified NPE.
  • openapi-asyncapi Overlay support: options.specs.openapi.<name>.overlay and options.specs.asyncapi.<name>.overlay were entirely unexposed in this binding (no schema, no adapter, no materialize() call), unlike the plain openapi/asyncapi bindings. Added schema, adapter round-trip, and materialize() for both specs in OpenapiAsyncapiCompositeGenerator, mirroring the established pattern exactly. Also threaded asyncapiSpec.security into AsyncapiSchemaConfig construction for parity with the openapi side and with binding-asyncapi's own composite generator.
  • mcp-openapi outbound credential forwarding: mcpHttpOptions() hardcoded null for the generated mcp_http binding's options.authorization, even though McpHttpBindingConfig.resolveCredentials() already supports {credentials}/{identity} header substitution downstream. Added options.authorization to binding-mcp-openapi (same {guard}: {credentials: {headers: {...}}} convention already used by binding-mcp and binding-mcp-http), resolving the guard's qualified name in McpOpenapiBindingConfig's constructor (mirroring AsyncapiBindingConfig's existing pattern) and forwarding it straight into the generated binding.
  • mcp-openapi Overlay support: options.specs.<name>.overlay was blocked by additionalProperties: false in the schema and had no adapter or generator support. Added the same schema/adapter/materialize() triad as the other bindings above.

The overlay/escape-hatch mechanism itself (JsonOverlay/JsonPath in common-json, and the OpenAPI-side wiring) was filed separately as #2127 and landed on develop via #2130; this PR extends that established pattern to the asyncapi, openapi-asyncapi, and mcp-openapi composite generators, per the "later change" the #2130 commit message called out for the sibling generators.

Independent re-audit — real bugs found and fixed

After the leak-closing pass above, a second independent re-audit of all four composite-generator bindings confirmed none of the fixes above regressed, and surfaced three genuine bugs (not just missing abstractions), all fixed in this PR:

  • binding-openapi: OpenapiOptionsConfigAdapter.adaptToJson threw an NPE when a spec's server had no url — the schema allows this, and adaptFromJson already null-checked the same field on the read path; adaptToJson didn't.
  • binding-mcp-openapi: a resource's template flag was computed from operation.path instead of the actual generated uri, so a query-only resource (e.g. /notifications{?unread}) was misclassified as static/concrete — violating the MCP resources/list contract, which requires a static resource's uri to be concrete. An existing test had been asserting the wrong behavior; fixed both the code and the test.
  • binding-asyncapi: options.specs.<name>.server could desync from the spec's own declared protocol. injectProtocols() chose the plain/secure injector variant (and therefore the exit target) purely from the spec's declared protocol, never consulting the override — producing either a dangling exit to a tls_client0 that was never created, or an unused tls_client0 left dangling with a silent plaintext downgrade. This exact mismatch already existed, undetected, in the checked-in client.kafka.yaml test fixture. Separately, injectKafkaServerOptions never applied the override to the Kafka broker host/port at all, unlike the equivalent HTTP/MQTT code paths. Fixed both.

Every change followed test-first discipline: a failing unit test (and, where applicable, k3po IT / schema fixture) confirmed red before the fix, green after. Full verify passes on runtime/binding-asyncapi, runtime/binding-openapi, runtime/binding-openapi-asyncapi, runtime/binding-mcp-openapi, runtime/common-asyncapi, runtime/common-openapi, and their specs/*.spec modules together, including checkstyle and JaCoCo coverage gates.

Follow-up abstraction-leak fixes

A third pass closed the remaining non-bug findings the re-audit had deferred:

  • binding-openapi-asyncapi: options.specs.openapi.<name>.server/.servers and options.specs.asyncapi.<name>.server/.servers were hardcoded to null/List.of() in OpenapiAsyncapiOptionsConfigAdapter, making them entirely unreachable regardless of what the operator configured — even though servers already feeds OpenapiView/AsyncapiView server-variable substitution downstream in OpenapiAsyncapiCompositeGenerator. Wired both read and write paths for both specs, mirroring OpenapiOptionsConfigAdapter/AsyncapiOptionsConfigAdapter, plus the matching schema patch properties.
  • binding-openapi-asyncapi: the x-zilla-http-kafka vendor extension's key/overrides fields were parsed onto OpenapiHttpKafkaOperationEx but never consumed — only .filters was read. Mirrored the sibling binding-asyncapi AsyncapiProxyGenerator's already-working produce-path handling: key overrides the Kafka message key (taking precedence over the auto-derived path-param/idempotencyKey default), and each overrides entry becomes a produce header override, with {identity} substitution via resolveIdentity().
  • binding-mcp-openapi: resources had no way to override the derived MCP mimeType, unlike description/output which already supported an operator override. Added mimeType to McpOpenapiResourceConfig/builder/adapter/schema, and prefer it over the OpenAPI-derived value in injectMimeType(). Along the way, found and fixed injectResourceOverrides() silently dropping mimeType (it copied fields one by one instead of forwarding the whole override config, so any future field would have been dropped the same way).
  • binding-mcp-openapi: injectMimeType()'s OpenAPI-derived fallback picked "the first" declared response content type via .values().iterator().next() on a map built with a bare Collectors.toMap — which defaults to HashMap, so with more than one declared content type the choice depended on hash bucket order, not spec declaration order. Fixed OpenapiResponseView.content to preserve declaration order and made the fallback prefer a JSON content type when present (mirroring the existing jsonContentType pattern in OpenapiAsyncapiProxyGenerator), falling back to the first declared entry otherwise.

Config surface change: collapse options.specs.*.servers to singular server

  • options.specs.<name>.servers (a list) is collapsed to a single options.specs.<name>.server override in both binding-openapi and binding-asyncapi. A spec has exactly one server override, not a list — the plural array shape never had a use case where more than one override made sense, and it invited exactly the kind of desync bug fixed above (binding-asyncapi's server/protocol mismatch).
  • when.servers route-condition matching now compares against the spec's own literal declared server value, not the override-resolved effective value — a route condition should select on what the spec itself declares, independent of any per-deployment override.
  • binding-openapi-asyncapi had separately picked up a server/servers field; reverted, since proxy-kind bindings never hold connection config of their own — that belongs to the openapi/asyncapi specs they reference.
  • Added when.servers/when.tag route-condition support to the openapi-asyncapi proxy and asyncapi proxy bindings, closing a gap where the openapi/asyncapi server-kind bindings already supported these conditions but their proxy-kind counterparts didn't.

Internal naming cleanup: apiId/apiLabel → spec vocabulary

A prior pass (#2079 and this PR) established spec/operation as the vocabulary for "which OpenAPI/AsyncAPI document a route condition refers to" (OpenapiConditionConfig, AsyncapiConditionConfig, OpenapiAsyncapiConditionConfig all already exposed spec/operation/matchesSpec/matchesOperation), but that rename never propagated into the surrounding layers — config adapters, composite-generation code, the composite/wire dispatch machinery, and all four stream factories still said apiId/apiLabel. A review pass closed that gap:

  • Tracing the actual data flow surfaced two genuinely distinct things that had both been called apiId:
    • A small, purely composite-local sequential index (0, 1, 2…) assigned per spec entry at composite-generation time, packed into a stream's compositeId alongside operationId/serverIndex. Never sent over the wire. Renamed to specIndex, matching the sibling serverIndex naming already used in the same bit-packing helpers (OpenapiCompositeId, AsyncapiCompositeId, OpenapiAsyncapiCompositeId).
    • The catalog schemaId a spec document resolved to, which flows wire-to-wire (OpenapiBeginEx/AsyncapiBeginEx's extension field, *CompositeConditionConfig, *CompositeConfig.resolve(...), all four stream factories). Renamed to specId.
  • apiLabel (the human-configured key under options.specs.<label>:) renamed to specLabel (or plain label where it already matched an existing field name).
  • resolveApiId, overloaded with opposite directions (String → long and long → String) sharing one name, split into resolveSpecId(String) → long and resolveSpecLabel(long) → String.
  • Scope: common-openapi, common-asyncapi, binding-openapi (+ .spec), binding-asyncapi (+ .spec), binding-openapi-asyncapi (+ .spec), and the binding-mcp-openapi.spec schema title. Includes the wire-level .idl extension field, regenerated flyweights, XxxFunctions builders/matchers, and every .rpt k3po fixture referencing it. binding-mcp-openapi's runtime code itself needed no changes — confirmed already clean, and rebuilt against the renamed common-openapi to verify.
  • Pure rename, no behavior change — verified by ./mvnw clean verify on each touched module (including the k3po IT suites, which construct/match the wire extension field by name) plus a full combined verify across all rename-touched modules together, plus a full ./mvnw clean install across the entire repository.
  • Two confirmed dead-code spots were renamed in place for consistency rather than deleted, and are flagged here rather than removed unprompted: OpenapiCompositeConfig's old resolveApiId(long) -> String overload (now resolveSpecLabel) has zero callers, and OpenapiAsyncapiCompositeId (now using specIndex) has zero callers in binding-openapi-asyncapi.
  • Collapsing the renamed specId with the pre-existing, separately-named schemaId it always mirrors in practice is a real simplification opportunity, deliberately left for a future pass — this PR only renames, it doesn't restructure. Canonicalizing composite-id handling at the stream-factory level (currently duplicated per binding) is tracked separately as Canonicalize/un-canonicalize request path and location values at the server/client stream-factory boundary #2145.

Deferred to follow-up issues

Findings from the audit that need a design decision rather than a mechanical fix are tracked separately to avoid blocking this PR:

One audit finding turned out not to be a bug on closer inspection: AsyncapiView/OpenapiView build their resolved servers list as a cross product of spec-declared servers × the operator's options.specs.<name>.servers override entries. This looked like an unintended blow-up when both sides declare more than one server, but binding-asyncapi's when.servers route condition (AsyncapiConditionServerConfig) already exists specifically to select down to the intended pairing by server name/url — the cross product is what lets a when.servers.name: primary condition transparently match every resolved connection variant of that named server. No fix needed there.

Docs updates for the new/changed options.* shapes above are handled separately, post-merge.

Fixes #2113

Test plan

  • ./mvnw verify -pl runtime/binding-asyncapi — unit tests, checkstyle, k3po ITs (incl. AsyncapiClientIT#shouldProduceMessage against the client.kafka.yaml fixture), coverage gates all pass
  • ./mvnw verify -pl specs/binding-asyncapi.spec — schema tests + k3po ITs pass
  • ./mvnw verify -pl runtime/binding-openapi,runtime/binding-openapi-asyncapi,runtime/binding-mcp-openapi,specs/binding-openapi.spec,specs/binding-openapi-asyncapi.spec,specs/binding-mcp-openapi.spec — all pass
  • ./mvnw verify -pl runtime/common-asyncapi,runtime/common-openapi — all pass
  • ./mvnw clean verify across all touched runtime/spec modules together in one reactor pass — no cross-module regressions
  • Red/green verified per change: new/extended unit tests fail without the fix (via git stash on the fix commit) and pass with it
  • Independent re-audit of all four composite-generator bindings post-fix, confirming no regressions and surfacing the three bugs above
  • Updated examples/asyncapi.mqtt.kafka.proxy to the new x-zilla-mqtt-kafka extension shape
  • Rebased onto develop after feat(common-json,binding-openapi): OpenAPI Overlay Specification support #2130 merged; resolved the one resulting conflict (both branches appended a test method to the same file)
  • Follow-up pass: options.specs.*.server/.servers reachability, x-zilla-http-kafka key/overrides consumption, and mcp-openapi resource mimeType override + deterministic content-type selection, each test-first with red/green confirmed
  • Full combined ./mvnw clean verify across all 9 apiId/apiLabel-rename-touched modules (common-openapi, common-asyncapi, binding-openapi, binding-asyncapi, binding-openapi-asyncapi, and their specs/*.spec modules), plus binding-mcp-openapi rebuilt as a downstream sanity check — all green, including every k3po IT suite
  • Full ./mvnw clean install across the entire repository — green; the only two failures hit were environment-only (a JaCoCo coverage threshold on unrelated, untouched binding-tcp from network-capability-limited IT skips in the local sandbox, and helm-chart's external chart-repo fetch blocked by sandbox network policy) and don't touch any code in this PR

jfallows pushed a commit that referenced this pull request Jul 11, 2026
…reflection

AsyncapiMqttKafkaChannelEx.role deserializes via reflective field access,
but the package wasn't opened in module-info.java. Unit tests run on the
classpath (no module boundary) so this passed locally, but the real
modular runtime image throws IllegalAccessException on startup, failing
config load for any spec using x-zilla-mqtt-kafka -- surfaced by the
asyncapi.mqtt.kafka.proxy example's CI healthcheck failure on PR #2128.

Confirmed by launching the engine directly on the module path against
the example config: reproduced the ConfigException before the fix,
and verified TCP port 7183 opens successfully after it.
claude added 6 commits July 11, 2026 06:27
…ve {identity} against the actual guard, not a hardcoded :jwt0

resolveIdentity() previously always rewrote {identity} to
${guarded['<namespace>:jwt0'].identity} regardless of which guard
`security` actually resolved for the operation. Thread the resolved
GuardedRef.qname through to each resolveIdentity call site instead;
when no guard resolves, leave {identity} unresolved rather than
referencing a guard that likely doesn't exist.

Consolidates the ad-hoc AsyncapiGuardResolver.resolve(...) calls in
AsyncapiProxyGenerator into the shared resolveGuarded()/guardQname()
helpers already used for allowed().

Fixes #2113 (item 4).
MQTT session/retained-message store selection was a global
options.mqtt.store, the only per-transport field in a binding whose
protocol mapping is otherwise entirely per-spec (security, catalogs,
servers). Move it under options.specs.<name>.store, consistent with
that pattern; ignored where the spec's protocol doesn't use it.

AsyncapiServerGenerator now reads the resolved store from the
per-schema AsyncapiSchemaConfig instead of the binding-wide
AsyncapiOptionsConfig.mqtt.store, falling back to the default
in-memory mqtt_store0 store when unset, same as before.

Fixes #2113 (item 2).
…rated Kafka client

KafkaOptionsConfig already mirrors HttpOptionsConfig/MqttOptionsConfig
with both a legacy sasl field and an authorization field resolvable
to a guard qname, but AsyncapiClientGenerator only ever read
options.kafka.sasl -- options.kafka.authorization was parsed and
schema-validated for every other transport but silently ignored for
Kafka, and had no schema entry at all on the asyncapi binding.

Resolve options.kafka.authorization.qname in AsyncapiBindingConfig
the same way http/mqtt authorization already are, and inject it into
the generated kafka_client0 binding's options alongside sasl.

Partial fix for #2113 (item 1a); guard multiplicity /
per-server-group guard divergence (item 1b) is tracked separately as
it is a larger design change, not a field wiring fix.
… routing

TlsConditionConfig already supports authority-based (SNI) routing --
used elsewhere in the codebase -- but OpenapiServerGenerator and
AsyncapiServerGenerator's injectTlsRoutes never populated it, only
port. Wire each declared server's hostname into the generated TLS
route condition so SNI-based dispatch works when multiple TLS servers
share a port.

This is the bounded, unambiguous part of #2113 (item
1b) -- wiring up an existing TlsConditionConfig capability. The
broader "generate one http_server0-equivalent per distinct-guard
server-group" change is left out of this PR: the issue itself flags
the guard-group derivation and dispatch design as an open question
the author hadn't resolved, and guessing at that shape risks building
something that has to be reworked once it's actually settled.
…la-mqtt-kafka extension

Channel-to-role mapping (sessions/messages/retained) for the MQTT-Kafka
proxy now lives on the Kafka spec itself, as an x-zilla-mqtt-kafka
extension on each channel, instead of a separate options.mqttKafka.channels
block that duplicated channel names the operator could get out of sync
with the spec. Resolves the mqttKafka.channels portion of #2113.
…reflection

AsyncapiMqttKafkaChannelEx.role deserializes via reflective field access,
but the package wasn't opened in module-info.java. Unit tests run on the
classpath (no module boundary) so this passed locally, but the real
modular runtime image throws IllegalAccessException on startup, failing
config load for any spec using x-zilla-mqtt-kafka -- surfaced by the
asyncapi.mqtt.kafka.proxy example's CI healthcheck failure on PR #2128.

Confirmed by launching the engine directly on the module path against
the example config: reproduced the ConfigException before the fix,
and verified TCP port 7183 opens successfully after it.
@jfallows
jfallows force-pushed the claude/zilla-issue-2113-plan-8l38nm branch from d8e9e59 to efcd94a Compare July 11, 2026 06:32
claude added 2 commits July 11, 2026 06:53
… spec is parsed

Extends the OpenAPI Overlay integration pattern from #2130 to asyncapi:
an optional options.specs.<label>.overlay reference, shaped like the
existing catalog reference, is resolved via the same CatalogHandler and
its JsonOverlay actions are applied to the resolved spec payload before
AsyncapiParser parses it. Mirrors OpenapiCompositeGenerator.materialize()
and OpenapiSpecificationConfig/OpenapiOptionsConfigAdapter exactly.

Ref: #2127
…r mqtt-kafka role error

options.kafka.topics[].defaultOffset and deltaType were accepted by the
schema (reused from binding-kafka's own topic schema) but never applied
to the generated kafka_cache_client0/kafka_cache_server0 topic options --
an operator asking for defaultOffset: historical silently got live
instead. Also guards against the missing-transforms case this exposed:
injectKafkaTopicConfig now only builds a transforms block when the
operator actually configured one, instead of NPEing on any topic entry
that sets defaultOffset/deltaType without transforms.

Separately, injectMqttKafkaOptions NPEd with no context when a Kafka
spec's x-zilla-mqtt-kafka extension was missing one of the three
required roles (sessions/messages/retained). requireMqttKafkaRole now
reports which role is missing.

Found via an options.* abstraction-leak audit of the composite-generator
bindings, following up on #2113.
claude added 3 commits July 11, 2026 08:01
…ncapi specs, thread asyncapi security to schema config

Extends the Overlay materialize() pattern (already present in binding-openapi
and binding-asyncapi) to binding-openapi-asyncapi's composite generator,
for both the openapi and asyncapi legs. Previously options.specs.*.overlay
was not exposed in this binding's schema/adapter at all, so operator-supplied
overlays were silently unreachable.

Also threads asyncapiSpec.security into AsyncapiSchemaConfig construction,
matching the parity already present on the openapi side and in binding-asyncapi's
own composite generator. Consuming that value for Kafka-side guard resolution
is tracked separately in #2133, since it requires a design
decision (Zilla routes support only one guard per route).

Ref: #2113
…dential forwarding

Adds options.authorization (name + credentials.headers, matching the same
convention used by binding-mcp and binding-mcp-http) so mcp-openapi can
declare a guard whose resolved credentials/identity get forwarded into the
generated mcp_http binding's outbound headers via {credentials}/{identity}
substitution -- a mechanism McpHttpBindingConfig.resolveCredentials() already
supports but mcp-openapi's composite generator never exposed, always passing
null.

The guard name is resolved to its qualified name in McpOpenapiBindingConfig's
constructor, mirroring AsyncapiBindingConfig's existing authorization.qname
resolution pattern, so the composite generator can wire it straight into the
generated binding without re-resolving.

Ref: #2113
Extends the Overlay materialize() pattern (already present in binding-openapi,
binding-asyncapi, and binding-openapi-asyncapi) to binding-mcp-openapi's
composite generator. Previously options.specs.<name>.overlay was blocked by
additionalProperties: false in the schema and had no adapter or generator
support, so an operator-supplied overlay was unreachable.

Ref: #2113
@jfallows jfallows changed the title fix(binding-asyncapi,binding-openapi-asyncapi,binding-openapi): close options.* abstraction leaks fix(binding-asyncapi,binding-openapi,binding-openapi-asyncapi,binding-mcp-openapi): close options.* abstraction leaks Jul 11, 2026
claude added 11 commits July 11, 2026 18:20
OpenapiOptionsConfigAdapter.adaptToJson threw an NPE when a spec's server
had no url configured, even though the schema allows it and adaptFromJson
already null-checks the same field on the read path.
…rated uri

McpOpenapiCompositeGenerator computed the template flag from
operation.path, but resourceUri() can append an RFC 6570 query-capture
suffix ({?param}) even when the path itself has no {pathParam} segments.
This misclassified query-only resources as static/concrete, producing a
uri containing an unexpanded {...} expression on a resource advertised
via resources/list, which violates the MCP contract (a static resource's
uri must be concrete). Fixed the existing test's assertion, which had
been asserting the wrong behavior.
…istently govern protocol security and Kafka broker address

Two related bugs in AsyncapiClientGenerator when a spec's server: override
disagrees with the AsyncAPI spec's own declared server protocol:

- injectProtocols() selected the http/mqtt/kafka injector variant (and
  therefore the generated binding's exit target) purely from the spec's
  declared protocol, never consulting the override's security class. This
  produced a dangling exit to a tls_client0 binding that injectTlsClient()
  never created (override plain, spec secure), or a silent plaintext
  downgrade with an unused tls_client0 left dangling (override secure,
  spec plain). This exact mismatch already existed undetected in the
  checked-in client.kafka.yaml fixture, invisible only because its IT
  drives the internal kafka0 stream directly, bypassing the network/TLS
  exit chain.
- injectKafkaServerOptions() built the Kafka client's broker host/port
  solely from the spec's declared servers, never from the override --
  unlike injectHttpOptions/injectMqttOptions, which both already apply it.

Added resolveProtocol() to normalize a declared protocol to its plain/secure
variant based on the override when present, and threaded resolveServer()
into injectKafkaServerOptions to mirror the existing HTTP/MQTT pattern.
…achable

OpenapiAsyncapiOptionsConfigAdapter hardcoded server=null and servers=List.of()
when parsing openapi specs, and never parsed server/servers at all for asyncapi
specs, so the override was silently dropped no matter what the operator
configured. servers (the list) already feeds OpenapiView/AsyncapiView server
variable substitution downstream in OpenapiAsyncapiCompositeGenerator, so
these values were previously unreachable regardless of user config.

Wire both read and write paths for openapi.server/servers and
asyncapi.server/servers, mirroring the existing OpenapiOptionsConfigAdapter and
AsyncapiOptionsConfigAdapter patterns, and add the matching schema patch
properties.
OpenapiHttpKafkaOperationEx.key and .overrides were parsed from the
x-zilla-http-kafka vendor extension but never read anywhere -- only .filters
was consumed. Mirror the sibling binding-asyncapi AsyncapiProxyGenerator's
already-working produce-path handling: key overrides the Kafka message key
(taking precedence over the auto-derived path-param/idempotencyKey default),
and each overrides entry becomes a produce header override, with {identity}
substitution via resolveIdentity().
Resources had no way to override the MCP mimeType derived from the OpenAPI
operation's success response content type, unlike description/output which
already supported an operator override. Add mimeType to McpOpenapiResourceConfig
and its builder/adapter/schema, and prefer it over the OpenAPI-derived value in
injectMimeType(). Also fixes injectResourceOverrides() silently dropping
mimeType (and would have dropped any future override field the same way,
since it copied fields one by one instead of the whole config).
…rce mimeType

injectMimeType() picked "the first" entry from OpenapiResponseView.content, a
map built via a bare Collectors.toMap that defaults to HashMap -- so with more
than one declared response content type, the chosen mimeType depended on hash
bucket order, not spec declaration order. Preserve declaration order in
OpenapiResponseView.content and prefer a JSON content type when present
(mirroring the existing jsonContentType pattern in
OpenapiAsyncapiProxyGenerator), falling back to the first declared entry.
…longside override-resolved ones

OpenapiServerView/AsyncapiServerView now expose literalUrl (and
literalHost/literalPathname for asyncapi) computed via the same
VariableMatcher against config=null always, plus an `overridden` flag
on OpenapiServerView recording whether a config override actually
matched this declared server's own pattern. These give downstream
when.servers matching a portable, deployment-independent value to
compare against, decoupled from whatever options.specs.*.server
override happens to be configured.
…rver, fix when.servers vanilla matching

options.specs.*.servers (plural override list) is redundant with the
spec document's own declared servers times a single deployment
override; no config anywhere ever configured more than one entry.
Collapse to the existing singular server override field.

when.servers.url now matches against the spec's own literal declared
value instead of the override-resolved effective value, so editing an
unrelated options.specs.*.server deployment override no longer
silently changes what a when.servers.url route condition matches.

Also fixes a double path-prefix bug this collapse would otherwise
surface: options.server composes a path prefix on top of each
doc-declared server only when the override does not itself match one
of those declared servers (the common reverse-proxy-in-front case);
when it does match (pinning a specific declared server, as in
server.env.prod.yaml), the matched server's own resolved url already
carries the correct path and the prefix must not be added again.
…erver, fix when.servers vanilla matching

Same collapse and vanilla-matching fix as binding-openapi:
options.specs.*.servers (plural) is dropped in favor of the existing
singular server override; when.servers.url now compares against
AsyncapiServerView.literalUrl instead of the override-resolved url.

Adds when.servers-driven route selection coverage for the asyncapi
proxy (mqtt-kafka mapping), previously an untested code path, plus a
case in AsyncapiConditionConfigAdapterTest pairing a server override
with a when.servers.url condition written against the spec's own
literal value to prove the override no longer desyncs the match.
…when.servers/when.tag route filtering

Reverts the recent options.specs.*.server/servers addition (proxy-kind
bindings hold no real connection, so a server override never belonged
here) and replaces it with when.servers/when.tag route conditions,
consistent with when.spec/when.operation and with the same conditions
now available on binding-openapi and binding-asyncapi.

OpenapiAsyncapiConditionConfig gains tag/servers fields and a new
matches(spec, operation, tags, servers) overload; the exact-match and
bulk/glob branches of OpenapiAsyncapiProxyGenerator.injectHttpKafkaRoutes
now call it before generating an http-kafka route, mirroring
AsyncapiProxyGenerator's existing ProxyOperationHelper.matches gate.
Filtering runs against the OpenAPI (HTTP) side's own declared
tags/servers, matching how when.spec/when.operation already resolve.
claude added 2 commits July 12, 2026 20:40
…roperty

The spec property's JSON-Schema title was never updated when the
property itself was renamed from apiId to spec.
apiLabel was the stale pre-rename name for the spec's own config label
(OpenapiSchemaConfig.specLabel, matching OpenapiSpecificationConfig.label).

apiId in OpenapiCompositeId's bit-packing was a separate, purely
composite-local sequential index (never sent over the wire, unrelated
to the schemaId-based identifier of the same old name elsewhere in the
runtime) - renamed to specIndex to match the sibling serverIndex
constant already in this same file, rather than reusing specId, the
name given to the wire-carried concept in a following change.
claude added 3 commits July 12, 2026 20:49
…Id to specId

OpenapiBeginEx.apiId was the stale pre-rename name for the resolved
spec's catalog schemaId, carried over the wire between the openapi
server/client stream factories. Renames the .idl field, the generated
flyweight's derived builder/matcher (via OpenapiFunctions), every .rpt
fixture referencing it, and every runtime call site (composite
condition/route/with configs, OpenapiCompositeConfig.resolveApiId
split into resolveSpecId/resolveSpecLabel, and the stream factory
fields/locals that read/write the wire field).
…piId to specId

Mirrors the binding-openapi rename: the wire-level AsyncapiBeginEx.apiId
field, XxxFunctions builder/matcher, all .rpt fixtures, and the runtime
composite condition/route/with configs, composite generators, and stream
factories now consistently use spec/specId/specLabel terminology instead
of the stale apiId/apiLabel naming. The composite-local sequential index
in AsyncapiCompositeId is renamed to specIndex to distinguish it from the
wire-carried catalog schemaId (specId).
…ame apiId/apiLabel to spec vocabulary

Mirrors the binding-openapi and binding-asyncapi renames: rpt fixtures,
condition/route/with configs, the composite generator, and the proxy
stream factory now consistently use spec/specId/specLabel instead of the
stale apiId/apiLabel naming. Also renames the dead-code
OpenapiAsyncapiCompositeId.apiId to specIndex for consistency with the
sibling common-openapi/common-asyncapi CompositeId helpers, and fixes
OpenapiAsyncapiConditionConfig.matchesSpec's param name, which previously
contradicted its own method name.
@jfallows jfallows changed the title fix(binding-asyncapi,binding-openapi,binding-openapi-asyncapi,binding-mcp-openapi): close options.* abstraction leaks fix(binding-asyncapi,binding-openapi,binding-openapi-asyncapi,binding-mcp-openapi): close options.* abstraction leaks and align spec/apiId terminology Jul 12, 2026
@jfallows
jfallows merged commit 2ebf827 into develop Jul 12, 2026
42 checks passed
jfallows pushed a commit to aklivity/zilla-docs that referenced this pull request Jul 12, 2026
…, and fail-open security

Reflects aklivity/zilla#2128 and #2079 on develop:

- options.authorization injects guard credentials into every generated
  upstream http request, mirroring mcp_http's own authorization option
- specs.overlay applies an OpenAPI Overlay document to the parsed spec
  before operations are extracted
- resources.mimeType overrides the auto-derived resource content type
- specs.security resolution is now fail-open: an unmapped security scheme
  is dropped rather than rejecting the operation; denial is now limited to
  OR-alternative security or multiple distinct guards in one alternative
jfallows added a commit that referenced this pull request Jul 14, 2026
…tory boundary (#2152)

* fix(binding-openapi,common-openapi): canonicalize openapi request shape at server/client boundary

Follow-up to #2113/#2128: implements #2145's canonicalize/un-canonicalize
proposal so openapi-asyncapi and downstream bindings operate purely on
canonical specId/operationId terms, never on options.specs.*.server.

Foundational fixes required first (found while implementing):

- options.specs.<label>.server now wholesale-replaces a single declared
  server's URL instead of falling back to the literal default and
  double-prefixing the override's path on top of it (server.route.prefix.yaml
  was asserting the resulting double-prefixed /apis/v1/pets as correct).
  Multi-server exact-match disambiguation (for when.servers routing) is
  preserved unchanged.
- TCP/TLS listen-address selection (ports/injectTcpRoutes/injectTlsRoutes)
  now reads literalUrl instead of url, since url can now diverge in
  scheme/host from the spec's own declared listen address once an override
  is wholesale-applied.
- Zero declared servers (at any level) now synthesize the OpenAPI-spec's
  own implicit {url: "/"} default instead of leaving servers null, fixing a
  pre-existing silent-unreachable-route/latent-NPE gap and removing a case
  the canonicalization logic would otherwise need to special-case.

Canonicalization itself:

- OpenapiServerFactory now rewrites the HttpBeginEx it forwards downstream:
  drops :scheme/:authority and rewrites :path down to the operation's own
  canonical (unprefixed) shape, via a new OpenapiBindingConfig.resolve(...)
  entry point.
- OpenapiClientFactory reconstructs the effective, deployment-specific
  shape (re-injecting :scheme/:authority, re-prefixing :path) via the
  symmetric OpenapiBindingConfig.resolve(...) overload before handing off
  to the generated http_client0 binding.
- OpenapiServerView gains effectivePrefixLength()/canonicalPrefixLength(),
  pure functions of url/literalUrl, used by both rewrite directions.
- binding-openapi-asyncapi needs no code change: it already always parses
  with an empty OpenapiServerConfig, so its generated http_kafka_proxy0
  when.path conditions were already canonical-shaped; they become correct
  now that the upstream bytes are too.

Verified: full ./mvnw verify green on runtime/binding-openapi,
runtime/common-openapi, specs/binding-openapi.spec, and
runtime/binding-openapi-asyncapi (unchanged, confirming no regression).

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

* refactor(common-openapi,binding-openapi): keep OpenapiServerView pure, derive canonical path from operation

OpenapiServerView (and OpenapiView/OpenapiOperationView) no longer take an
options.specs.*.server override at construction time - they stay a faithful,
config-free view of the parsed spec. Generators combine that pure view with
the binding's own options.specs.*.server via OpenapiBindingConfig.resolveEffectiveUrl,
instead of baking the override into the view itself.

This also simplifies the runtime (un)canonicalize transform at the
server/client boundary: canonicalizing no longer needs any prefix-length
arithmetic or config lookup at all - it just rebuilds :path from the already
resolved operation's own path against the canonical server. Un-canonicalizing
on the client side resolves the effective base (override or canonical) once
per BEGIN and reconstructs :scheme/:authority/:path from it.

Fixes the canonical path shape itself: it must retain the spec's own declared
server prefix (e.g. /v1/pets) rather than the bare operation path, which is
what the openapi-asyncapi proxy's independently generated Kafka route
already expects. Adds a red/green composite test
(shouldCreatePetWithServerPathPrefix) proving a server path-prefix override
combined with Kafka-proxying now routes correctly.

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

* refactor(binding-openapi): collapse resolveServerOverride+resolveEffectiveUrl into resolveServer

The two static helpers were always called back-to-back at every call site
(look up the override, then combine it with the canonical view), so fold
them into one instance method on OpenapiBindingConfig - the natural owner,
since it already holds the options this combination depends on.

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

* refactor(binding-openapi,common-openapi): options.specs.*.server drives TCP/TLS/HTTP uniformly, make it required

options.specs.*.server is meant to make the API's base URL wholesale
relocatable (per OpenAPI's own servers: semantics) - so it must drive TCP/TLS
listen address and HTTP path generation together, not just HTTP path while
TCP/TLS stay pinned to the spec's own declared server. Collapses
resolveServerOverride+resolveEffectiveUrl into a single resolveBaseURL(specLabel)
returning the resolved override URI directly (no server/singular argument
needed - override, when present, always wins wholesale, uniformly across every
declared server for that spec label, since there's exactly one physical
deployment target).

Since an override now determines physical bind behavior, options.specs.*.server
becomes a required field in the openapi binding's JSON schema (previously
optional) - omitting it left "does this spec have a real deployment address"
ambiguous. Existing fixtures whose override previously differed from the
physical listen address (e.g. https://frontend.example.com) are updated to a
value consistent with where they actually listen, to avoid needing to fabricate
TLS material just for the override's scheme to be real.

Fixture updates for the remaining configs that omitted options.specs.*.server
entirely are in progress as a follow-up commit.

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

* test(binding-openapi.spec): add required options.specs.*.server to config fixtures

Follow-up to 702dc0a, which made options.specs.*.server required in the
openapi binding's JSON schema. These fixtures previously omitted it entirely;
each now declares a server matching its own embedded spec's canonical
servers: url, so behavior is unchanged.

Remaining binding-openapi-asyncapi.spec fixtures still need the same fix.

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

* fix(binding-openapi.spec): fix stray closing brace in OpenapiClientGenerator, add missing server: fixture

OpenapiClientGenerator.injectHttpRequests had a leftover extra closing block
from an earlier edit (dropped the now-unneeded singular local but left its
enclosing braces behind). server.secure.yaml was missed by the earlier
required-server fixture pass because it also declares a `server:` vault,
which threw off the file-level grep check.

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

* refactor(binding-openapi): drop the no-override fallback now that server is required

resolveBaseURL never returns a missing override for a schema-valid config, so
the generators and OpenapiBindingConfig.resolve() no longer need to fall back
to each canonical server's own url. TCP/TLS/HTTP server generation and the
client's scheme/authority/path resolution now use a single resolved base URL
directly. Per-operation HTTP request/response validation entries collapse to
one per operation instead of one per declared canonical server, since they'd
otherwise be exact duplicates - only the per-server compositeId route
disambiguation in injectHttpRoutes still iterates every declared server,
since that's what lets OpenapiServerFactory resolve which canonical server
matched for routes[].when.servers filtering.

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

* refactor(binding-asyncapi): make options.specs.*.server required, drop no-override fallback

Mirrors the binding-openapi fix: options.specs.*.server is now schema-required
for server/client/proxy kinds, since a spec's declared server is meant to be
wholesale relocatable, not merged with a deployment-specific override. Drops
the now-dead null-server fallback branches in AsyncapiClientGenerator and
AsyncapiCompositeGenerator.

Known consequence, accepted: a multi-broker Kafka bootstrap list in a spec's
servers: collapses to the single configured override broker, since the
override is one address, not a list.

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

* feat(binding-openapi): options.specs.*.server(s) becomes a plural, relocatable base-URL list

Replace the singular required options.specs.<name>.server string with a
servers array (minItems 1). A spec's declared servers can now be relocated
to several equivalent deployment base URLs at once, not just one.

Server kind fans out TCP/TLS/HTTP route and request-template generation
across every configured server URI within the same tcp_server0/tls_server0/
http_server0 trio, instead of one physical listener per override.

Client kind keeps a single http_client0/tls_client0 pair; OpenapiClientFactory
now round-robins across the configured servers per (binding, spec) so every
entry is a real, reachable target, and drops the static ":authority" options
override that would have clobbered per-stream dynamic target selection.

Also removes routes[].when[].servers: tracing OpenapiServerFactory showed it
already matched against the canonical per-declared-server url while every
generated route for an operation carried an identical :path condition once
the override became uniform, so the filter had already gone silently inert.

repurpose server.route.servers.yaml as a multiple-servers regression fixture
now that its former when.servers-based route disambiguation is gone.

* test(binding-openapi): replace client round-robin unit test with a k3po IT

Drop OpenapiClientFactoryTest (this binding proves stream-factory behavior
through k3po ITs, not Mockito unit tests, matching every other test class in
this module). Add OpenapiClientIT#shouldRoundRobinAcrossServers instead: a
two-server client config with real accept sockets on two different ports,
proving consecutive requests actually land on both configured targets in
order, not just that the in-memory selector alternates.

* fix(binding-openapi): restore when.servers as generation-time filter, drop compositeId server-index

The options.specs.*.servers[] rollout introduced arbitrary compositeId
resolution whenever an operation declares more than one canonical server:
injectHttpRoutes looped the canonical-server axis outer and the deployment
override axis inner, so every canonical variant produced an identical :path
condition and first-match-wins made compositeId's server-index arbitrary.
Since compositeId drove canonicalize's server lookup, a request could be
canonicalized against the wrong declared server.

Separate the two axes that were conflated: deployment relocation
(options.specs.*.servers[], a pure runtime concern, unchanged) from
canonical declared-server scoping (a pure generation-time concern). Restore
when.servers as a generation-time inclusion filter only (not a runtime
route disambiguator) — it now decides which operations a route's config
includes, based on the operation's own declared servers.

Once inclusion is decided once at generation time, compositeId no longer
needs a server-index component at all: canonicalize only needs the bare
operation path, and un-canonicalize only needs the resolved deployment URI
plus the path already on the wire. This eliminates the bug structurally.

Also fixes canonicalize/un-canonicalize to use the operation's bare path as
the canonical form, rather than prefixing with the canonical server's own
base path, removing the need to resolve "which declared server" at runtime.

* fix(binding-mcp-openapi): drop stale 4-arg OpenapiView.of(...) call

OpenapiView.of dropped its trailing List<OpenapiServerConfig> parameter
when OpenapiServerView was made pure (713dcd4), but this call site was
never updated and always passed an empty list for it — a no-op that only
now surfaced as a compile break with the plain 3-arg overload in scope.
Drop the extra argument; behavior is unchanged.

* refactor(common-asyncapi): drop vestigial server-index from AsyncapiCompositeId

AsyncapiCompositeId carried the same bit-packed server-index dimension
that OpenapiCompositeId had before it caused a real correctness bug
(#2145) -- but here it was always dead: no production code ever called
the 3-arg constructor or read serverIndex(), since AsyncapiOperationView
has no per-operation canonical-server concept to disambiguate in the
first place. Removing it now so the shape can't be reused the same
broken way if per-channel server scoping (see #2150) is ever added.

* Revert "refactor(common-asyncapi): drop vestigial server-index from AsyncapiCompositeId"

This reverts commit 2042e3d.

* Reapply "refactor(common-asyncapi): drop vestigial server-index from AsyncapiCompositeId"

This reverts commit e6c8c27.

* fix(binding-asyncapi): wire per-operation servers into when.servers[] routing

Swap the three call sites that fed the coarse, spec-wide server list into
AsyncapiConditionConfig/AsyncapiBindingConfig.resolve for the real,
per-operation-scoped list added by #2151: AsyncapiProxyGenerator's
generation-time route matching, and AsyncapiServerFactory/AsyncapiProxyFactory's
runtime route dispatch. A channel scoped to a subset of a spec's servers now
correctly excludes routes whose when.servers[] condition targets a different
server.

Realign the composite/asyncapi mqtt and kafka k3po fixtures' hardcoded
compositeId literals with AsyncapiCompositeId's simplified 2-field
(specIndex, operationId) encoding now that the vestigial server-index
dimension is gone.

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

* test(binding-asyncapi): add overlay k3po IT, trim generator unit tests

Add a new AsyncapiServerIT scenario (shouldPublishToChannelAddedByOverlay)
proving AsyncapiServerGenerator applies an options.specs.*.overlay document
before generating routes, using a channel/operation only present after the
overlay merge. Existing shouldPublishAndSubscribe/shouldPublishAndSubscribeWithStore
already exercise configured-vs-default MQTT store selection end to end, so
those two AsyncapiServerGeneratorTest cases are redundant and removed.

Trim AsyncapiServerGeneratorTest, AsyncapiProxyGeneratorTest, and
AsyncapiClientGeneratorTest down to only the assertions that have no
reasonable k3po IT equivalent, documenting the specific blocker on each
class: an attach-time exception message with no IT-visible surface, a
servers[]-scoping condition only reachable via an internal-composite-origin
dispatch path with no k3po test harness support for kind: proxy, and
Kafka SASL/TLS/host-port wiring that only takes effect on a real outbound
broker connection the existing IT intentionally bypasses.

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

* fix(binding-asyncapi): canonicalize HTTP/SSE server pathname; fix combination bug

AsyncapiServerGenerator never combined a declared server's pathname
(servers.*.pathname) with the channel address when generating HTTP/SSE
request paths and routes, so a spec-compliant client prefixing requests
with that pathname would 404. Fix by prepending the resolved pathname(s)
to the channel address in injectHttpRequests/injectHttpRoutes/injectSseRequests/
injectSseRoutes.

Also canonicalize the HTTP/SSE inner extension at AsyncapiServerFactory's
exit (strip :scheme/:authority, rewrite path to the canonical channel
address template) and un-canonicalize it at AsyncapiClientFactory's entry
(reapply the resolved server URI and pathname), mirroring the existing
OpenapiServerFactory/OpenapiClientFactory canonicalization. MQTT carries no
non-relocatable server info in its BeginEx and is left untouched (already
covered by existing byte-for-byte MQTT scripts).

Update existing HTTP/SSE k3po fixtures to reflect the new canonical form
and add new pathname-specific server/client ITs.

* fix(binding-asyncapi.spec): align SSE peer-to-peer script with canonical form

AsyncapiSseIT runs asyncapi/sse/data.multiple/client and /server directly
against each other without Zilla, so both sides must already agree on the
canonical (stripped scheme/authority) SseBeginEx shape now that
AsyncapiServerFactory canonicalizes it. Only the server-side matcher was
updated previously; align the client-side builder to match, fixing the CI
failure on PR #2152.

Also add the missing peer-to-peer IT coverage for the new
create.pet.pathname scenario in AsyncapiHttpIT/CompositeHttpIT, per the
one-scenario-needs-both-a-binding-IT-and-a-peer-to-peer-IT convention.

* fix(examples): add required server/servers config to openapi/asyncapi examples

The openapi and asyncapi binding schemas require options.specs.*.server
(asyncapi, singular string) or options.specs.*.servers (openapi, array),
but several example configs predate that requirement and were missing it
entirely, so Zilla failed engine config validation on startup.

Verified all seven openapi/asyncapi examples end-to-end against a locally
built image from this branch: openapi.proxy, openapi.asyncapi.kakfa.proxy,
asyncapi.http.kafka.proxy (sync + async flows), asyncapi.mqtt.kafka.proxy,
asyncapi.mqtt.proxy, asyncapi.sse.kafka.proxy, asyncapi.sse.proxy.

* fix(binding-asyncapi): use options.specs.*.servers (plural) for consistency with openapi

Aligns the asyncapi binding's server override config with the already-migrated
openapi binding shape: options.specs.<label>.server (single string) becomes
options.specs.<label>.servers (array, minItems 1, required).

- AsyncapiSpecificationConfig.servers is now a List<String>; the builder's
  serverOverride(String) accumulates repeated calls into that list
- AsyncapiCompositeGenerator builds one AsyncapiServerConfig per configured
  server and cross-products them against the AsyncAPI document's own
  declared servers, same as before but generalized from exactly one entry
- AsyncapiBindingConfig.resolveServers(specLabel) resolves the configured
  URIs, mirroring OpenapiBindingConfig.resolveBaseURLs
- AsyncapiClientFactory now round-robins across multiple configured servers
  per (bindingId, specLabel) when resolving the HTTP/SSE un-canonicalize
  target, mirroring OpenapiClientFactory.selectServer
- Updated the asyncapi JSON schema patch and every spec/example fixture
  referencing the old singular server: key

* fix(binding-openapi-asyncapi): stop re-prefixing route-match path with server base path

http_kafka_proxy0's route condition combined the OpenAPI document's declared
server base path into its :path match, even though by the time a request
reaches this internal route, openapi_server0 has already canonicalized :path
down to the bare operation path. Match on the bare path instead.

Updates the two script pairs that connect directly to composite0 (bypassing
the canonicalizing server) to send/expect the now-bare path; their Location
header values, produced independently by the async-produce config, are
unaffected.

* fix(binding-http-kafka): correlate correlater flow-control state to its own domain, not the shared delegate's

KafkaCorrelateProxy.onKafkaReset compared and wrote delegate.initialAck,
a field shared with the sibling KafkaProduceProxy. When an async POST's
produce leg advances delegate.initialAck (via its own window accounting)
after the correlater's begin-time snapshot, the fetch-domain reset
acknowledge no longer satisfies delegate.initialAck's invariant, crashing
the worker. Compare/write the correlater's own local initialAck/initialSeq
instead, matching its sibling onKafkaWindow.

* feat(binding-openapi): un-canonicalize response Location header at server exit

Issue #2145 asks to canonicalize/un-canonicalize both request path and
location values. OpenapiServerFactory already canonicalized the request
path but passed the reply-direction Location header straight through in
bare, canonical form, never reapplying the deployment's configured server
path prefix.

Add OpenapiBindingConfig.resolveServer (finds which configured
options.specs.*.servers[] entry the real incoming request matched) and
resolveLocation (reapplies that server's path prefix onto a bare Location
header). OpenapiServerFactory's OpenapiStream stores the matched server as
a plain per-stream field, set in the request-direction doOpenapiBegin and
read back in the reply-direction onOpenapiBegin, since one OpenapiStream
instance already handles both directions of the same exchange.

* feat(binding-asyncapi): un-canonicalize response Location header at server exit

Mirrors the OpenAPI-side fix for issue #2145's location-values half.
AsyncapiServerFactory canonicalized the request path but passed the
reply-direction Location header straight through in bare, canonical form,
never reapplying the operation's declared server pathname.

Add AsyncapiBindingConfig.resolveLocation (HTTP-only, gated the same way
as canonicalize/resolve dispatch on SSE having no Location semantics),
prepending the resolved pathname onto a bare Location header. Promote
resolvePathname from AsyncapiClientFactory's private static helper to a
shared AsyncapiBindingConfig method so AsyncapiServerFactory can reuse it;
AsyncapiClientFactory now delegates to it instead of keeping its own copy.
AsyncapiServerFactory threads the resolved pathname through AsyncapiStream
and calls resolveLocation in the reply-direction onAsyncapiBegin.

* fix(binding-openapi-asyncapi): fix flow-control relay bugs and stale correlation-id matcher unblocking shouldVerifyCustomerAsync

Route-matching fix in 05179aa let shouldVerifyCustomerAsync's async
produce/correlate/fetch path execute for the first time, surfacing several
latent bugs it never previously reached:

- CompositeClientStream.doCompositeWindow relayed replyPad into an
  initial-direction window, and doCompositeFlush used the wrong-domain
  budgetId; both are no-op violations on what should be a transparent relay
- HttpKafkaProxyFactory: missing `+ reserved` on two FLUSH sequence
  trackers, a parameter-order swap in doKafkaEndAck, and a missing
  correlater window refresh in onHttpWindow
- The correlate-listener's advisory flush never reached the wire because
  the correlation-id embedded in its filter no longer matched the request's
  canonical :path (see below), so the k3po script never got past its begin
  match; test fixtures hardcoded the stale pre-canonicalization hash

Root cause of the correlation-id mismatch, and of getVerifiedCustomer being
misrouted through HttpProduceAsyncProxy instead of HttpCorrelateAsyncProxy
(producing a 400 instead of 204): OpenapiAsyncapiProxyGenerator still built
the GET's correlation-id extraction regex from
httpServer.requestPath(v.schema.format), which re-prepends the server's
path prefix. Everything internal to the composite operates on canonical,
prefix-stripped paths -- 05179aa fixed the route-match path but missed
this second call site, so the regex could never match the canonical :path
it actually sees at runtime, correlation-id extraction failed, and the
code fell back to generating a random idempotency key.

Fixed by building the matcher from the bare v.schema.format. Updated the
.rpt fixtures' stale correlation-id hash and Location prefix to match.

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

* fix(binding-openapi-asyncapi): drop vestigial per-server route duplication

injectHttpKafkaRoute looped over httpOp.servers to generate one route per
declared OpenAPI spec-server, threading the OpenapiServerView through to
injectHttpKafkaRouteWith/FetchWith/ProduceWith. None of those methods used
it once route-path canonicalization removed the last httpServer.requestPath
call, so the loop only produced duplicate, byte-for-byte identical routes
per spec-server. Collapse it to generate the route once per operation.

* refactor(common-asyncapi): purify AsyncapiServerView, drop config baking

AsyncapiServerView took an AsyncapiServerConfig at construction and baked
a deployment override into .url/.host/.pathname, while separately
computing config-independent literalUrl/literalHost/literalPathname
fields for when.servers[] route matching. Drop the config parameter
entirely -- .url/.host/.pathname now always resolve to the spec's own
declared default, identical to what the literal* fields used to compute,
so the separate fields become redundant. Mirrors the same purification
already done on OpenapiServerView.

AsyncapiView/AsyncapiCompositeId no longer take or cross a
List<AsyncapiServerConfig>; delete AsyncapiServerConfig/
AsyncapiServerConfigBuilder outright, matching the OpenAPI side (no
OpenapiServerConfig equivalent exists there either).

* refactor(binding-asyncapi,binding-openapi-asyncapi): drop config crossing at AsyncapiView.of

Follows the AsyncapiServerView purification -- neither composite
generator needs to build an AsyncapiServerConfig list anymore since the
view no longer takes one.

* refactor(binding-asyncapi): match when.servers[].url against pure .url

server.literalUrl no longer exists; server.url now computes the exact
same config-independent value directly, since the view is pure.

Deletes shouldMatchServerByLiteralUrlRegardlessOfOverride -- its premise
(comparing an overridden view against a literal one) is gone by
construction; the invariant it proved is redundant with existing
spec-variable-default coverage.

* refactor(binding-asyncapi): fan out AsyncapiServerGenerator over resolveServers()

TCP listener ports, plain/secure TCP routing, TLS SNI routes, and
protocol-family dispatch used to read .port/.hostname/.protocol off the
config-crossed AsyncapiServerView list. Now that the view is pure, these
fan out over AsyncapiBindingConfig.resolveServers(specLabel) instead --
a List<URI> parsed directly from options.specs.*.servers[], deriving
plain-vs-secure and protocol-family dispatch from URI.getScheme() rather
than the spec's own protocol field. Mirrors OpenapiServerGenerator's
resolveServers() pattern exactly; AsyncapiClientGenerator/
AsyncapiClientFactory already worked this way.

resolvePathnames(operation) is untouched -- it correctly continues
reading operation.servers/.protocol/.pathname off the now-pure view,
since neither field was ever affected by config baking in practice.

AsyncapiServerGeneratorTest.shouldPopulateTlsAuthorityForSniRouting
needs an explicit serverOverride now that resolveServers() is the
source of TLS listener ports/authorities.

* fix(binding-asyncapi.spec): scheme-prefix server-side options.specs.*.servers[]

resolveServers() parses each entry via URI.create, which needs a scheme
to correctly extract host:port -- a schemeless "host:port" string parses
as an opaque URI (host becomes the scheme) rather than an authority.
Client-side fixtures already used scheme-prefixed strings; server-side
ones were bare. Scheme-prefix every server-side fixture to match its own
already-declared spec-level protocol. No behavior change -- resolved
ports/hosts are numerically identical, only the parsing mechanism
changed.

* refactor(common-asyncapi,binding-asyncapi): parse AsyncapiServerView address as one URI

AsyncAPI 3.0 splits what 2.x expressed as a single `url` into `host`
(may include port) + `protocol` + `pathname`, intended to reconstruct as
`{protocol}://{host}{pathname}`. AsyncapiServerView kept these as four
separate fields instead (url, host, hostname, port), with hostname/port
derived through a synthetic "tcp://"+host wrapper that ignored both the
real protocol and pathname. All four had zero consumers left outside the
view's own constructor -- orphaned once TCP/TLS generation moved to
resolveServers() earlier in this branch's history.

Replace them with a single `url` (URI), composed from host+protocol+
pathname for 3.0-style documents or parsed directly for legacy 2.x `url`
declarations, mirroring OpenapiServerView.url exactly. pathname/protocol
stay as their own fields -- pathname because URI.getPath() would turn a
genuinely-absent pathname into "" instead of null, changing existing
nonNull-filtering behavior in AsyncapiBindingConfig.resolvePathname/
AsyncapiServerGenerator.resolvePathnames; protocol because its call
sites are clearer than .url.getScheme() would be.

This also fixes a real bug: AsyncapiConditionServerConfig.matches (the
when.servers[].url route filter) compared against the legacy url string,
which is always null for a spec-compliant 3.0 document (host+protocol
documents have no url property at all per the AsyncAPI 3.0 schema) -- so
when.servers[].url silently never matched on any 3.0 spec. Now compares
against the composed URI's string form, working for both spec styles.

* refactor(common-asyncapi,binding-asyncapi): fold pathname into AsyncapiServerView.url

pathname was kept as its own field alongside the newly-unified url on
the stated concern that URI.getPath() returns "" for a path-less
hierarchical URI while pathname was null, and both consumers
(AsyncapiBindingConfig.resolvePathname, AsyncapiServerGenerator's
resolvePathnames) filtered on Objects::nonNull. On closer look that
distinction wasn't protecting a real invariant -- both callers already
fall back to "" at the end regardless, and the null-filter's only
actual effect was silently dropping a server that declares no pathname
whenever another server for the same operation/spec does declare one,
which is a bug (that server's un-prefixed route stops being generated),
not a feature worth preserving.

Folding also fixes a related latent gap: pathname was populated only
from AsyncAPI 3.0's separate `pathname` field, so a legacy 2.x server
declaring `url: https://host/v1` had its embedded /v1 path silently
ignored for HTTP route generation. url.getPath() picks it up correctly
regardless of which spec style produced it.

protocol stays its own field (not url.getScheme()) -- it's the
document's directly-declared value rather than something re-derived
from a parsed URI, and its call sites read more clearly as .protocol.

* refactor(common-asyncapi,binding-asyncapi): fold protocol into AsyncapiServerView.url

protocol duplicated what url's own scheme already carries: for the
host+protocol (3.0) branch, url is composed using model.protocol as
the scheme directly, so url.getScheme() equals protocol by
construction; for the legacy url-style branch, the declared protocol
was a separately-trusted value alongside the address actually used for
routing, rather than derived from it. Drop the field and read
url.getScheme() at all four call sites instead (AsyncapiView.hasProtocol,
AsyncapiBindingConfig.resolvePathname, AsyncapiServerGenerator's
resolvePathnames, AsyncapiClientGenerator's protocol-family dispatch),
so the address actually used for routing/generation is the single
source of truth for its own scheme, with no separately-synthesized
value to drift from it.

* refactor(binding-asyncapi): rename resolvePathname(s) to resolvePath(s)

AsyncapiServerView.url is now a single parsed URI, so these methods
return a URI path component, not a legacy pathname string.

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

* refactor(binding-asyncapi): rename remaining pathname identifiers to path/serverPath

AsyncapiServerGenerator's per-operation loop variables now read as
plain URI path values (path). The deployment-path-prefix threaded
through AsyncapiServerFactory/AsyncapiClientFactory/AsyncapiBindingConfig's
resolve/resolveLocation family is renamed to serverPath to avoid
colliding with the existing path parameter in requestPath().

Left untouched: AsyncapiServer.pathname (the AsyncAPI 3.0 Server Object's
own JSON property name) and AsyncapiServerView's constructor locals that
parse it directly.

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

* fix(examples): fix flaky asyncapi.sse.proxy test race

The sse-server test double broadcasts events live with no buffering:
if curl's SSE subscription hasn't finished connecting through Zilla
before the event is published via nc, it's lost for good. The old
script backgrounded curl and published immediately, racing the
subscription's HTTP/2 upgrade handshake — reproduced the same drop
connecting straight to the sse-server, bypassing Zilla entirely.

Wait for the subscription to establish before publishing, and retry
the whole cycle using the shared retry_until helper, matching the
pattern already used by other examples in .github/test-lib.sh.

Verified locally: 6/6 clean passes after the fix, versus frequent
failures before it.

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

---------

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.

Follow-up: consolidate remaining options.* abstraction leaks in openapi/asyncapi

2 participants