Repository navigation
Fixes #28152: Add NATS JetStream Messaging Connector - #32122
Conversation
harshach
left a comment
There was a problem hiding this comment.
NATS connector quality review
Verdict: APPROVED — 9.5/10
| Category | Score |
|---|---|
| Schema and registration | 9.6/10 |
| Connection and authentication | 9.7/10 |
| Source, topology, and performance | 9.5/10 |
| Test quality | 9.2/10 |
| Code quality and style | 9.5/10 |
Final finding count: 0 blockers, 0 warnings, 0 actionable suggestions.
Findings identified and resolved
- Removed the misleading
jetStreamEnabled=falsemode, which could not discover core-NATS subjects and silently returned an empty catalog. - Replaced the flat authentication fields with an exclusive schema union for basic, token, and NKey credentials; anonymous access remains available by omitting authentication.
- Registered NATS in
BETA_SERVICESso the UI status matches the connector's release stage. - Replaced swallowed/masked JetStream API failures with contextual errors and explicit pagination-response validation.
- Added
BaseConnectionownership and deterministic drain/close behavior. - Hardened TLS temporary-file cleanup, including failures during partial certificate/key materialization.
- Made the optional schema test step report real failures instead of becoming a silent no-op.
- Removed the N+1
STREAM.INFOpattern by consuming detailed, paginatedSTREAM.LISTresponses. - Made recent-message sampling tolerate stream sequence gaps while keeping the scan bounded.
- Added a 1 MiB aggregate sample-size cap in addition to the ten-message count limit.
- Preserved valid UTF-8 exactly and base64-encoded binary payloads instead of using lossy replacement decoding.
- Added contextual validation for non-object JSON returned by NATS API requests.
- Strengthened integration helpers and pagination tests by removing silent exception handling and asserting actual offsets.
Verification evidence
- 91 focused unit tests pass with 92% connector coverage (
connection.py99%,metadata.py85%, models/service 100%). - Schema/model generation, OpenMetadata spec compilation, TypeScript schema parsing, i18n generation, app-doc generation, connector type checking, Python formatting/linting, and changed-file UI checkstyle pass.
- The integration suite successfully starts NATS JetStream and creates its fixture streams. Its local OpenMetadata step requires rebuilding the already-running server from this branch because that server revision predates the new
Natsenum. - The static analyzer's "No unit tests found" message is a path-detector false positive; tests live at
ingestion/tests/unit/source/messaging/test_nats.py.
The connector-quality review is complete. Separately, the pull request should remain a draft until the repository-required UI recording is attached.
| return { | ||
| "replication_factor": config.num_replicas, | ||
| "max_message_size": config.max_msg_size, | ||
| "retention_size": config.max_bytes, | ||
| "cleanup_policies": _NATS_RETENTION_TO_CLEANUP.get(config.retention, ["delete"]) | ||
| if config.retention | ||
| else None, | ||
| "topic_config": topic_config, | ||
| } |
There was a problem hiding this comment.
💡 Edge Case: NATS unlimited (-1) limits stored as negative topic sizes
JetStream returns max_bytes and max_msg_size as -1 (and max_age as 0) when a stream has no limit configured — e.g. the integration test's users and events streams. _build_topic_config_params passes these straight through, so retentionSize and maximumMessageSize are written to OpenMetadata as -1 instead of unset, producing misleading negative sizes in the topic entity. Normalize non-positive sentinels to None so unlimited streams show no size rather than -1.
Treat NATS -1/0 unlimited sentinels as None so they are not stored as negative sizes.:
def _positive_or_none(value):
return value if value and value > 0 else None
...
return {
"replication_factor": config.num_replicas,
"max_message_size": _positive_or_none(config.max_msg_size),
"retention_size": _positive_or_none(config.max_bytes),
"cleanup_policies": _NATS_RETENTION_TO_CLEANUP.get(config.retention, ["delete"])
if config.retention
else None,
"topic_config": topic_config,
}
Was this helpful? React with 👍 / 👎
| securityConfig: | ||
| jwtToken: "eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5MmotMDI0MmJrOTQzNTYiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlzQm90IjpmYWxzZSwiaXNzIjoib3Blbi1tZXRhZGF0YS5vcmciLCJpYXQiOjE2NjM5Mzg0NjIsImVtYWlsIjoiYWRtaW5Ab3Blbm1ldGFkYXRhLm9yZyJ9.tS8um_5DKu7HgzGBzS1VTA5uUjKWOCU0B_j08WXBiEC0mr0zNREkqVfwFDD-d24HlNEbrqioLsBuFRiwIWKc1m_ZlVQbG7P36RUxhuv2vbSp80FKyNM-Tj93FDzq91jsyNmsQhyNv_fNr3TXfzzSPjHt8Go0FMMP66weoKMgW2PbXlhVKwEuXUHyakLLzewm9UMeQaEiRzhiTMU3UkLXcKbYEJJvfNFcLwSl9W8JCO_l0Yj3ud-qt_nQYEZwqW6u5nfdQllN133iikV4fM5QZsMCnm8Rq1mvLR0y9bmJiD7fwM1tmJ791TUWqmKaTnP49U493VanKpUAfzIiOiIbhg" |
There was a problem hiding this comment.
The example stores a complete JWT directly under securityConfig.jwtToken, exposing a reusable credential in repository history and propagating it into copied configurations instead of sourcing authentication from an environment variable or secrets manager.
How this was verified: The changed workflow contains the complete JWT literal in its authentication configuration.
Context Used: CLAUDE.md (source)
There was a problem hiding this comment.
Pull request overview
Adds a new schema-first NATS JetStream messaging connector to OpenMetadata’s ingestion framework, wiring it end-to-end through the spec → generated models/types → UI connection form + icons/docs, along with unit and integration coverage.
Changes:
- Introduces
NatsConnectionschema + registersNatsas aMessagingServiceType(spec + UI wiring + generated types). - Implements the Python ingestion source for NATS JetStream (connection handling, stream discovery, optional KV-backed schema ingestion, bounded sampling).
- Adds unit + integration tests and a workflow example for running NATS ingestion.
Reviewed changes
Copilot reviewed 20 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-ui/src/main/resources/ui/src/utils/ServiceIconUtils.ts | Registers the NATS service icon for UI rendering. |
| openmetadata-ui/src/main/resources/ui/src/utils/MessagingServiceUtils.ts | Adds lazy-loader entry for the NATS connection schema in the service form. |
| openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.interface.ts | Adds formatted display label for NATS in messaging service type formatting. |
| openmetadata-ui/src/main/resources/ui/src/jsons/connectionSchemas/connections/messaging/natsConnection.json | Adds UI-consumed JSON schema for NATS connection configuration. |
| openmetadata-ui/src/main/resources/ui/src/generated/metadataIngestion/workflow.ts | Regenerated types to include NATS connection fields in workflow config models. |
| openmetadata-ui/src/main/resources/ui/src/generated/metadataIngestion/testSuitePipeline.ts | Regenerated types to include NATS connection fields in test-suite pipeline models. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/services/messagingService.ts | Regenerated messaging service entity types to include MessagingServiceType.Nats and NATS connection shape. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/services/ingestionPipelines/serviceProgressEvent.ts | Regenerated ingestion pipeline progress event types with NATS additions. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/services/ingestionPipelines/ingestionPipeline.ts | Regenerated ingestion pipeline entity types with NATS additions. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/services/connections/serviceConnection.ts | Regenerated service connection union types to include NATS connection config. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/services/connections/messaging/natsConnection.ts | New generated TS interface/enums for NatsConnection. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/data/topic.ts | Updates generated MessagingServiceType to include Nats for topic entities. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/automations/workflow.ts | Regenerated automation workflow types to include NATS connection fields. |
| openmetadata-ui/src/main/resources/ui/src/generated/entity/automations/testServiceConnection.ts | Regenerated automation test-connection types to include NATS connection fields. |
| openmetadata-ui/src/main/resources/ui/src/generated/api/services/ingestionPipelines/createIngestionPipeline.ts | Regenerated API request typings to include NATS connection options. |
| openmetadata-ui/src/main/resources/ui/src/generated/api/services/createMessagingService.ts | Regenerated API typings for creating messaging services with NATS connection config. |
| openmetadata-ui/src/main/resources/ui/src/generated/api/automations/createWorkflow.ts | Regenerated API typings for creating workflows with NATS connection config. |
| openmetadata-ui/src/main/resources/ui/src/constants/ServiceType.constant.ts | Marks MessagingServiceType.Nats as Beta in the UI service picker. |
| openmetadata-ui/src/main/resources/ui/public/locales/en-US/Messaging/Nats.md | Adds UI field-level help documentation for the NATS connector. |
| openmetadata-spec/src/main/resources/json/schema/entity/services/messagingService.json | Registers Nats as a messaging service type and adds connection $ref. |
| openmetadata-spec/src/main/resources/json/schema/entity/services/connections/messaging/natsConnection.json | Adds schema-first connection config definition for NATS. |
| openmetadata-service/src/main/resources/json/data/testConnections/messaging/nats.json | Adds backend test-connection step definitions for NATS. |
| ingestion/tests/unit/source/messaging/test_nats.py | Adds unit test suite covering NATS connector behavior (auth, pagination, schema, sampling, cleanup). |
| ingestion/tests/integration/nats/test_metadata.py | Adds integration assertions validating streams become topics and basic metadata is set. |
| ingestion/tests/integration/nats/populate_schemas_kv.py | Adds helper script to populate a JetStream KV bucket with schemas for testing. |
| ingestion/tests/integration/nats/populate_nats.py | Adds helper script to create streams and publish sample messages for testing. |
| ingestion/tests/integration/nats/conftest.py | Adds testcontainers-based NATS JetStream fixture + service creation + workflow config fixture. |
| ingestion/tests/integration/nats/init.py | Initializes the NATS integration test package. |
| ingestion/src/metadata/ingestion/source/messaging/nats/service_spec.py | Registers the NATS connector via BaseSpec. |
| ingestion/src/metadata/ingestion/source/messaging/nats/models.py | Adds Pydantic models for JetStream stream config/state parsing. |
| ingestion/src/metadata/ingestion/source/messaging/nats/metadata.py | Implements NATS JetStream discovery → topic creation, optional schema from KV, and bounded sampling. |
| ingestion/src/metadata/ingestion/source/messaging/nats/connection.py | Implements connection ownership/cleanup, TLS handling, and test-connection steps. |
| ingestion/src/metadata/ingestion/source/messaging/nats/init.py | Initializes the NATS messaging source module. |
| ingestion/src/metadata/examples/workflows/nats.yaml | Adds a runnable ingestion workflow example for NATS. |
| ingestion/setup.py | Adds nats extra dependency (nats-py) for ingestion packaging. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| except (ValueError, UnicodeDecodeError): | ||
| logger.debug( | ||
| "Skipping non-text sample at sequence %s from NATS stream %s", | ||
| seq, | ||
| topic_details.topic_name, |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 36 changed files in this pull request and generated no new comments.
Suppressed comments (1)
ingestion/src/metadata/ingestion/source/messaging/nats/metadata.py:351
- This sample-data path currently skips non-UTF-8 payloads (UnicodeDecodeError/ValueError) rather than base64-encoding them. That contradicts the PR description (“base64-encodes binary data”) and means binary streams will show fewer/no samples even when they are within the byte/sample limits.
Consider either (a) encoding binary payloads as base64 strings (optionally with a clear prefix/metadata) and updating unit tests accordingly, or (b) updating the PR description/docs to explicitly state that binary payloads are omitted from samples.
except (ValueError, UnicodeDecodeError):
logger.debug(
"Skipping non-text sample at sequence %s from NATS stream %s",
seq,
topic_details.topic_name,
❌ UI Checkstyle Failed❌ ESLint + Prettier + Organise Imports (src)One or more source files have linting or formatting issues. ❌ Licence HeaderOne or more files are missing or have an outdated Apache 2.0 licence header. Affected files
🔍 ESLint findings in this PR's files — ESLint report could not be read — see the job log.Errors block the build. Warnings do not yet — they are rules whose backlog is still No machine-readable report was produced. Fix locally (fast - only checks files changed in this branch): make ui-checkstyle-changed |
|
|
`src/jsons/` is dereferenced from openmetadata-spec by the `parse-schema` postinstall and is gitignored wholesale; every other connection schema in it is untracked. natsConnection.json was force-added in #32122 in its prettier-formatted form, which the generator does not produce — so `yarn install` rewrites it and leaves the tree dirty, and UI Checkstyle fails the git-status gate at the end of its first step on every PR. Co-Authored-By: Claude Opus 5 <[email protected]>
…le (#32138) * fix(ui): untrack generated natsConnection.json to unblock UI Checkstyle src/jsons/connectionSchemas/** is generated output: .gitignore:100 ignores the tree, and `yarn parse-schema` (postinstall -> build-check) rmSyncs and rewrites it on every install. #32122 force-added the NATS connection schema into it, in prettier's formatting rather than the `JSON.stringify(obj, null, 2)` form parseSchemas.js emits. The two formats can never agree - JSON.stringify always expands arrays and never writes a trailing newline - so every CI run regenerates the file, dirties the working tree before any check executes, and fails whichever `git status --porcelain` gate in ui-checkstyle.yml runs first: "ESLint + Prettier (src)" for PRs touching src/**, "Licence Header" for everything else. Merge-queue UI Checkstyle has been red since the NATS commit landed. Untrack the file - it is rebuilt at install time, and the spec source under openmetadata-spec/ stays committed - and mirror ESLint's `src/jsons/connectionSchemas/**` ignore into .prettierignore so prettier cannot rewrite generated schemas again. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(ui): cover all five parse-schema output dirs in .prettierignore runParsers() in parseSchemas.js regenerates connectionSchemas/connections, ingestionSchemas, governanceSchemas, applicationSchemas and configuration. The first pass listed only three, leaving governanceSchemas/ and configuration/ open to the same prettier-vs-JSON.stringify conflict. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
… install `src/jsons/**` was gitignored and regenerated by `parse-schema` on every `yarn install` (via `postinstall` -> `build-check`). Three files had been force-added past that ignore rule (#29964, #32122). Once tracked, every CI run regenerated them, and because the committed content did not match the generator's output byte-for-byte the working tree came up dirty before any linting ran. ui-checkstyle gates on `git status --porcelain`, so it failed on main for every PR regardless of what that PR changed. Commit the generated output instead, the same way `src/generated/` TypeScript types are handled: - drop the `src/jsons/*` ignore rule and track all 279 generated files - remove `parse-schema` from `build-check`, so `yarn install` and the Maven build no longer rewrite tracked files; `yarn parse-schema` stays available for manual regeneration - exclude `src/jsons/` from Prettier, the licence-header check, and ESLint (the ESLint ignore is widened from `src/jsons/connectionSchemas/**`), and from the changed-file list in `ui-checkstyle-changed.sh`, so no formatter can reintroduce drift between the committed files and generator output Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…on install (open-metadata#32150) * build(ui): track dereferenced JSON schemas instead of regenerating on install `src/jsons/**` was gitignored and regenerated by `parse-schema` on every `yarn install` (via `postinstall` -> `build-check`). Three files had been force-added past that ignore rule (open-metadata#29964, open-metadata#32122). Once tracked, every CI run regenerated them, and because the committed content did not match the generator's output byte-for-byte the working tree came up dirty before any linting ran. ui-checkstyle gates on `git status --porcelain`, so it failed on main for every PR regardless of what that PR changed. Commit the generated output instead, the same way `src/generated/` TypeScript types are handled: - drop the `src/jsons/*` ignore rule and track all 279 generated files - remove `parse-schema` from `build-check`, so `yarn install` and the Maven build no longer rewrite tracked files; `yarn parse-schema` stays available for manual regeneration - exclude `src/jsons/` from Prettier, the licence-header check, and ESLint (the ESLint ignore is widened from `src/jsons/connectionSchemas/**`), and from the changed-file list in `ui-checkstyle-changed.sh`, so no formatter can reintroduce drift between the committed files and generator output Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * ci(ui): auto-update dereferenced JSON schemas alongside generated types `src/jsons/**` is now tracked, so it needs the same drift protection `src/generated/**` already has. typescript-type-generation.yml: run `yarn parse-schema` next to `json2ts-generate-all.sh`, stage `src/jsons/` with `src/generated/`, and trigger on changes to `src/jsons/**` and `parseSchemas.js`. Same behaviour as before for both cases: auto-commit on same-repo PRs, fail with instructions on fork PRs. ui-checkstyle.yml: add `src/jsons/**` to `files_ignore` so generated schemas are never passed to ESLint/Prettier/organise-imports. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(ui): fail parse-schema loudly instead of emitting partial output parseSchemas.js caught every error and only logged it, so the process exited 0 no matter how many schemas failed to generate. That was harmless while src/jsons was gitignored and rebuilt on every install, but the previous commit tracks that output — and main() clears each destination directory before regenerating it. A transient failure (an unresolvable $ref, a read error) now leaves the schema *missing*, the auto-update workflow reads that as a deletion, and on a same-repo PR the bot force-pushes a commit removing a tracked file, with no CI signal. Collect failures instead of swallowing them and set a non-zero exit code, so the workflow stops before its "Check for changes" step. Errors are still collected rather than thrown, so one bad schema does not mask the others: the run reports every failure at once. Verified by injecting an unresolvable $ref into kafkaConnection.json — exit 1, six schemas reported, and `git status` confirmed those six would otherwise have been staged as deletions. Restoring the schema returns the run to exit 0 with byte-identical output. --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>



Describe your changes
Fixes #28152.
Supersedes #28153. This replacement applies the completed NATS connector work cleanly on the current
mainbranch without a merge commit. The connector commit retains the original author, Rafael Grecco ([email protected]).This adds a schema-first NATS JetStream messaging connector with:
Type of change
High-level design
NatsConnectionas the schema source of truth and regenerates the Java, Python, and TypeScript models. Registers NATS in the ingestion registry, messaging service enum, UI service metadata, and beta-service list.BaseConnection, validates API responses, owns connection cleanup, removes temporary TLS files on partial failures, and reports contextual connection/API errors.STREAM.LISTresponses to avoid oneSTREAM.INFOrequest per stream. Subjects become topics under their JetStream stream container.Tests
Unit tests
ingestion/tests/unit/source/messaging/test_nats.pyconnection.py99%,metadata.py85%, models/service 100%).source env/bin/activate pytest -c ingestion/pyproject.toml ingestion/tests/unit/source/messaging/test_nats.py \ --cov=metadata.ingestion.source.messaging.nats --cov-report=term-missing -qBackend integration tests
Ingestion integration tests
ingestion/tests/integration/nats/nats:2.10with JetStream, creates representative streams/messages, creates the OpenMetadata service, runs ingestion, and validates the resulting topics and samples.8cb4..., which predates the newNatsenum, so it rejected the new service type with HTTP 400. Rebuilding the local server from this branch is required to complete that environment-level run.Playwright tests
Other verification
The exact UI checkstyle sequence (organize imports, ESLint, Prettier, and license-header verification) passes for every changed UI file.
basedpyrightreports zero errors for the connector and its tests.UI recording
Connector quality review
The
/connector-reviewprocedure was run against the complete replacement diff.Verdict: APPROVED from the connector-quality perspective. The final pass has 0 blockers, 0 warnings, and 0 remaining actionable suggestions. The PR remains a draft only because the UI recording above is outstanding.
The review identified and this replacement resolves issues involving authentication exclusivity, unsupported non-JetStream behavior, beta registration, swallowed API errors, connection ownership and cleanup, pagination validation, N+1 stream requests, sampling gaps and byte bounds, binary payload handling, optional schema-test behavior, and integration-test assertions/error handling.
The static connector analyzer's only remaining message is a false positive claiming no unit tests because it checks a legacy test path; the 91 unit tests are present under
ingestion/tests/unit/source/messaging/.Checklist
Greptile Summary
The PR adds schema-first NATS JetStream support across ingestion, shared service contracts, generated UI models, service registration, documentation, and integration coverage.
Confidence Score: 3/5
The PR is not yet safe to merge because the example workflow still publishes an administrative JWT that must be replaced with secret-backed configuration.
The NKey dependency issue is fixed by installing the nats-py NKey extra, but the complete administrative JWT remains committed in the NATS workflow example and continues to violate the repository’s credential-handling boundary.
Files Needing Attention: ingestion/src/metadata/examples/workflows/nats.yaml
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR C[NATS connection configuration] --> J[JetStream connection] J --> D[Paginated stream discovery] D --> T[OpenMetadata topic requests] J --> K[Optional schema KV lookup] K --> T J --> S[Bounded sample retrieval] S --> P[Topic sample data] T --> O[OpenMetadata REST sink] P --> OReviews (4): Last reviewed commit: "fix(nats): include NKey authentication d..." | Re-trigger Greptile
Context used (4)