Skip to content

fix: harden v1.0.0 trust — MCP ESM crash, concurrency races, CLI/API drift, CI/release - #1

Merged
ritikbansod merged 1 commit into
mainfrom
fix/quick-wins
Sep 28, 2026
Merged

ritikbansod merged 1 commit into
mainfrom
fix/quick-wins

Conversation

@ritikbansod

Copy link
Copy Markdown
Owner

Quick-win fix batch from a deep code analysis of the repo (18 findings, every one independently reproduced by a second reviewer before being fixed). One PR, small verified changes, no feature work.

What's fixed

MCP server (high)

  • mcp/kview-mcp.js crashed on startup on Node <= 22.6 (SyntaxError: Cannot use import statement outside a module) because it is ESM in a .js file with no package.json. Fixed by shipping mcp/package.json with "type": "module". CI now smoke-tests the MCP server startup on Node 20 — exactly the check that would have caught this.

Concurrency (4)

  • DynamicConsumerService: check-then-act race on subscribe() could leak a permanently running consumer container. Subscribe/unsubscribe are now serialized, group buffers are freed when the group's last subscription ends, and all containers stop on shutdown (@PreDestroy).
  • RegistrySettingsStore: find() on the decode hot path read a plain LinkedHashMap while writers structurally mutated it — now a ConcurrentHashMap.
  • SchemaRegistryService: schema-registry cache loads (remote HTTP, 10s timeout) ran inside one shared lock, so a slow or unreachable registry stalled every decode cluster-wide — now per-key locking.
  • KafkaClusterManager: get() could hand out a handle that a concurrent evict() was closing — now mutually excluded.

Tests

  • Both integration suites overrode a wrong property name (kafka-wrapper.data-dir vs the code's kview.data-dir), so the scheduled partition-history sampler rewrote the developer's real ./data directory on every test run. Both now point at target/.

CLI/API drift (3)

  • kview lag <group> read a non-existent byTopic field and silently printed zero lag rows — now reads partitionsByTopic as the API serializes it.
  • kview clusters tabled a securityProtocol field the API never returns — now derived from the masked security object.
  • README's reset-offsets my-group latest example failed (--topic is required) — corrected to the real flag form.

Docs / project hygiene

  • README roadmap and COMPATIBILITY.md no longer describe the shipped Schema Registry support (Avro/JSON, v1.0.0) as unbuilt.
  • Internal working documents (QA-REPORT.md, RELEASE-PLAN.md, SCHEMA-REGISTRY-PLAN.md) moved from the repo root to docs/.
  • Removed the divergent legacy kview-cli.js (hardcoded /api/clusters/default/, different command names); cli/kview.mjs is the CLI.

Release / build trust

  • release.yml built released artifacts with -DskipTests and extracted a VERSION no step consumed, while the version was pinned in three places — artifacts are now built test-green, and a guard fails the release unless the tag matches pom.xml, cli/kview.mjs and mcp/kview-mcp.js.
  • Added the Maven wrapper (./mvnw) so a clone builds with just a JDK.

Verification

  • Full suite green through the new wrapper: ./mvnw -B clean test → 30/30 tests pass.
  • MCP startup smoke: node mcp/kview-mcp.js < /dev/null starts (16 tools) and exits 0 — previously a SyntaxError, exit 1.
  • CLI smoke: --version / --help OK.

Not covered here (deliberate follow-ups): API authentication (the high-severity unauthenticated-API finding — that's feature F1, next in the roadmap), the Spring Boot 3.3.4 → 3.5.x bump, and runtime checks against a live broker.

…drift, CI/release

Verified issues from a deep code analysis (18 findings, all independently confirmed):

- mcp: ship mcp/package.json ("type": "module") — kview-mcp.js crashed on
  startup on Node <= 22.6 with SyntaxError: Cannot use import statement
  outside a module
- consumer: serialize DynamicConsumerService subscribe/unsubscribe (race
  could leak a permanently running container), free per-group buffers after
  the last unsubscribe, stop containers on shutdown
- schema: RegistrySettingsStore map is now a ConcurrentHashMap (decode hot
  path raced writers); schema-registry cache loads lock per key instead of
  one shared lock (a slow registry stalled all decodes cluster-wide)
- connection: KafkaClusterManager get/evict are mutually excluded so a
  handle is never handed out while being closed
- test: both integration suites now point kview.data-dir at target/ (the
  wrong property name made them rewrite the real ./data on every run)
- cli: kview lag reads partitionsByTopic (was a non-existent byTopic field,
  silently printing zero lag rows); kview clusters derives SECURITY from the
  masked security object the API actually returns
- docs: correct the reset-offsets example, stop describing the shipped
  Schema Registry support as unbuilt, move QA-REPORT/RELEASE-PLAN/
  SCHEMA-REGISTRY-PLAN to docs/, remove the divergent legacy kview-cli.js
- ci: smoke-test the MCP server startup on Node 20 (would have caught the
  ESM crash)
- release: build with the test suite green; a tag must match the versions
  in pom.xml, cli/kview.mjs and mcp/kview-mcp.js
- build: add the Maven wrapper (./mvnw) so a clone builds with just a JDK
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.

1 participant