fix: sanitize NATS JetStream consumer name (replace dots with dashes)#1131
Merged
fix: sanitize NATS JetStream consumer name (replace dots with dashes)#1131
Conversation
| /// Generate consumer name: user-specified or auto from query ID | ||
| /// Generate consumer name: user-specified or auto from query ID. | ||
| /// NATS consumer names must not contain '.' or ' ', so sanitize. | ||
| String consumer_name = getConsumerName(); |
Collaborator
There was a problem hiding this comment.
may need initial consumer name in ctor and update getConsumerName() for consistency
b11ad39 to
72e8ffd
Compare
yuzifeng1984
approved these changes
Mar 16, 2026
72e8ffd to
b048276
Compare
NATS consumer names must not contain '.' or ' '. The auto-generated
consumer name (proton-{query_id}) includes dots from materialized view
query IDs (e.g. .mv-xxxx), causing "Invalid Argument" errors when
creating MV subscriptions. Replace invalid characters with dashes.
Move sanitization to validateSettings() for user-specified names so
getConsumerName() always returns a valid NATS name. Pass the resolved
consumer name explicitly to NATSJetstreamSource for consistency across
stall recovery and fetch subscriptions.
Add NATS JetStream smoke test suite (0032_external_stream_nats) with
coverage for basic read/write, table(), RawBLOB, virtual columns,
materialized views, and drop/recreate. Add NATS + nats-setup services
to the p1k1 Docker Compose deployment.
Co-Authored-By: Claude <[email protected]>
Made-with: Cursor
b048276 to
af0f860
Compare
Collaborator
Author
|
flaky ? Some tests failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NATS consumer names must not contain
.(dots) or spaces. This is enforced by the NATS server because dots are the subject token delimiter in NATS subject-based addressing (e.g.orders.us.east). Allowing dots in consumer names would create ambiguity with the subject namespace. The NATS server rejects anyjs_PullSubscribecall with a consumer name containing.with anInvalid Argumenterror.The auto-generated consumer name in Proton uses the format
proton-{query_id}. For materialized views, the query ID contains dots (e.g..mv-95861997-136d-4030-8298-f68745e50f04), producing names like:This causes
CREATE MATERIALIZED VIEWagainst a NATS JetStream external stream to fail with:Fix: Sanitize the auto-generated consumer name by replacing
.and spaces with-before passing it to the NATS C client. This applies to both user-specified and auto-generated consumer names. The sanitized nameproton--mv-95861997-136d-4030-8298-f68745e50f04is valid and works correctly.Reference: NATS naming conventions -- consumer names follow the same rules as stream names: alphanumeric,
-,_, no.or spaces.Test plan
CREATE MATERIALIZED VIEW ... FROM nats_jetstream_streamsucceeds without explicitconsumer_nameconsumer_namewith dots (e.g.my.consumer) is also sanitized