Skip to content

Enforce store requirement for MQTT server bindings - #1963

Merged
jfallows merged 1 commit into
developfrom
claude/gracious-curie-5avmps
Jun 24, 2026
Merged

jfallows merged 1 commit into
developfrom
claude/gracious-curie-5avmps

Conversation

@jfallows

Copy link
Copy Markdown
Contributor

Description

This change makes the store option mandatory for MQTT server bindings by enforcing it at the schema validation level, rather than relying on runtime warnings.

Changes

Schema & Validation:

  • Updated mqtt.schema.patch.json to require options with a store property for server bindings
  • Added server.without.store.yaml test configuration to verify that configurations without a store are rejected
  • Added schema validation test shouldRejectServerWithoutStore() to ensure the requirement is enforced

Code Cleanup:

  • Removed the deprecated runtime warning logic from MqttServerFactory.attach() that warned about missing store configuration
  • Removed the warnSessionOwnershipDeprecated() method that is no longer needed

Configuration Updates:

  • Updated all MQTT server test configurations to include explicit store definitions
  • Updated example configurations (mqtt.kafka.proxy, mqtt.proxy.jwt) to include store setup
  • Updated AsyncAPI server generator to automatically inject a memory store when MQTT options are configured

Bug Fix:

  • Fixed condition in MqttKafkaSessionFactory to only process unacked packet IDs when the queue is not empty, preventing unnecessary stream creation

Rationale

By moving the store requirement from a runtime warning to a schema-level constraint, configurations are validated at load time rather than runtime. This ensures all MQTT server bindings have proper session storage configured before the application starts, improving reliability and preventing runtime surprises.

Test Plan

Existing schema validation tests pass, including the new test that verifies rejection of server configurations without a store. All updated example and test configurations now include proper store configuration.

https://claude.ai/code/session_01Vx4B6SkggrTs8EEEenxPtp

…y packet queue

The QoS2 session "#offsets" choreography introduced in PR #1806 drives its
ack state machine off the Kafka offset-commit stream WINDOW frames:
onKafkaWindow routes the first WINDOW to onOffsetCommitOpened (seed) and
every subsequent WINDOW to onOffsetCommitAck. After the seed commit is
acked the session stream is created and offsetCommitSeeded is cleared, so
any further flow-control WINDOW falls into the else branch and calls
unackedPacketIds.remove() on an empty queue, throwing NoSuchElementException.

That exception propagates as an AgentTerminationException and kills the
engine worker, taking down every binding on the worker — which is why the
mqtt.kafka.proxy and asyncapi.mqtt.kafka.proxy example smoke tests fail to
complete the MQTT CONNECT on develop.

WINDOW frames are flow-control credit and do not map one-to-one to produce
acks, so only pop a packet id when one is actually pending (a real QoS2
offset commit added it via doCommitOffsetComplete); otherwise the WINDOW is
just additional credit and is ignored.

Verified by running the mqtt.kafka.proxy example end-to-end against real
Kafka: the worker no longer crashes and the publish/subscribe round-trip
succeeds.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vx4B6SkggrTs8EEEenxPtp
@jfallows
jfallows force-pushed the claude/gracious-curie-5avmps branch from 00f56a4 to e49a387 Compare June 24, 2026 18:55

Copy link
Copy Markdown
Contributor Author

Reduced this PR to the single root-cause fix and force-pushed.

What broke develop: the QoS2 session #offsets choreography from #1806 drives its ack state machine off the Kafka offset-commit stream's WINDOW frames. After the seed commit is acked, any further flow-control WINDOW hit unackedPacketIds.remove() on an empty queue → NoSuchElementException → AgentTerminationException, killing the engine worker and taking down every binding on it. That's why the mqtt.kafka.proxy and asyncapi.mqtt.kafka.proxy example smoke tests couldn't complete the MQTT CONNECT. Fix: only pop a packet id when one is actually pending; a WINDOW is flow-control credit, not a produce ack.

Verified locally end-to-end against real Kafka (built the develop-SNAPSHOT image): the worker no longer crashes and both examples' publish/subscribe round-trip succeeds.

Scope change: I'd also staged a feat(binding-mqtt)!: require store on mqtt server binding change here, but it regresses the binding-mqtt integration suite (activating the store-ownership handshake under the engine test store alters/aborts the CONNACK in several IT scenarios; the memory store used by the examples is fine). Since the crash fix alone unblocks develop, that work has been moved out to a dedicated follow-up PR where the IT/k3po fallout can be worked through properly. This PR is now just the one-line binding-mqtt-kafka fix.


Generated by Claude Code

@jfallows jfallows left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jfallows
jfallows merged commit 9fe7bfb into develop Jun 24, 2026
41 checks passed
@jfallows
jfallows deleted the claude/gracious-curie-5avmps branch July 1, 2026 23:05
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.

2 participants