Skip to content

Keep Kafka version fallback on metadata.version - #1905

Open
reachsrinivaschennupati-tech wants to merge 1 commit into
kafbat:mainfrom
reachsrinivaschennupati-tech:fix/831-msk-version-fallback
Open

Keep Kafka version fallback on metadata.version#1905
reachsrinivaschennupati-tech wants to merge 1 commit into
kafbat:mainfrom
reachsrinivaschennupati-tech:fix/831-msk-version-fallback

Conversation

@reachsrinivaschennupati-tech

@reachsrinivaschennupati-tech reachsrinivaschennupati-tech commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What changed

This reworks the previous approach based on maintainer feedback. The PR no longer uses log.message.format.version as a Kafka version fallback.

Instead, broker config version extraction is limited to the exact inter.broker.protocol.version config key. If that value is unavailable, the existing metadata.version fallback from describeFeatures remains the next source, and the existing Unknown display fallback remains unchanged.

Why

log.message.format.version is deprecated for newer Kafka versions and is not a reliable source for the displayed Kafka broker version. Without real MSK DescribeConfigs / describeFeatures output proving otherwise, keeping metadata.version as the fallback is the safer behavior.

Tests

Added focused unit coverage for Kafka version extraction:

  • uses inter.broker.protocol.version when present
  • ignores log.message.format.version
  • returns empty when the broker protocol version is missing or null, allowing the existing metadata.version fallback path to run

Local focused Gradle test was attempted with:

NPM_CONFIG_CACHE=/private/tmp/kafka-ui-npm-cache ./gradlew :api:test --tests io.kafbat.ui.service.ReactiveAdminClientVersionTest

It could not complete locally because this machine only has JDK 17 installed while the project currently compiles with source release 25.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Kafka version detection by consistently using the configured inter-broker protocol version.
    • Correctly handles missing or null version settings without returning an incorrect version.
  • Tests

    • Added coverage for valid, missing, null, and unrelated Kafka version configurations.

@reachsrinivaschennupati-tech
reachsrinivaschennupati-tech requested a review from a team as a code owner July 10, 2026 01:39
@kapybro kapybro Bot added status/triage/manual Manual triage in progress and removed status/triage/manual Manual triage in progress labels Jul 10, 2026
@kapybro

kapybro Bot commented Jul 10, 2026

Copy link
Copy Markdown

AI Summary

The issue addresses a problem where Kafka version fallback logic for Amazon MSK clusters doesn't properly use log.message.format.version when inter.broker.protocol.version is unavailable. The proposed solution adds this fallback and maintains existing fallbacks like metadata.version and Unknown, along with unit tests to verify version extraction precedence. Testing is blocked due to a Java version mismatch.

@kapybro kapybro Bot changed the title Fix Kafka version fallback for MSK clusters Use log.message.format.version as fallback for Kafka version in MSK clusters Jul 10, 2026
@kapybro kapybro Bot added area/brokers Broker / broker configs related issues type/bug Something isn't working type/enhancement En enhancement/improvement to an already existing feature labels Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Kafka version extraction now uses a named inter.broker.protocol.version key. A helper resolves its first non-null value before topic-deletion processing. Tests cover present, alternate, null, and absent configurations.

Changes

Kafka version extraction

Layer / File(s) Summary
Version resolution and config integration
api/src/main/java/io/kafbat/ui/service/ReactiveAdminClient.java
A named key and helper centralize extraction of the first non-null inter.broker.protocol.version value.
Version resolution validation
api/src/test/java/io/kafbat/ui/service/ReactiveAdminClientVersionTest.java
Tests cover preferred values, ignored log.message.format.version, null values, and absent configurations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: alexeyzavyalov

Poem

A rabbit checks the broker line,
Finds the protocol value fine.
Null or missing? None is shown.
Tests confirm what can be known.
Config hops in tidy time.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR changes Kafka version detection but does not implement issue #831's required change from 1.0-UNKNOWN to UNKNOWN. Change the unidentified cluster version value to UNKNOWN, then retain or separately justify the MSK fallback changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes target Kafka cluster-version extraction and related tests, so no unrelated code changes are shown.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to Kafka version fallback behavior, which is a real aspect of the changes, but it does not fully describe the primary extraction update.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi reachsrinivaschennupati-tech! 👋

Welcome, and thank you for opening your first PR in the repo!

Please wait for triaging by our maintainers.

Please take a look at our contributing guide.

@reachsrinivaschennupati-tech

Copy link
Copy Markdown
Contributor Author

Hi maintainers, this PR is ready for review when you have a chance.

The change is scoped to Kafka version detection for MSK-style broker configurations: inter.broker.protocol.version remains the first choice, log.message.format.version is used as the next fallback, and the existing metadata/unknown fallbacks are preserved.

Validation noted in the PR:

  • Focused unit tests were added for version extraction precedence.
  • Local Gradle execution was blocked in the earlier environment by the Java version mismatch noted in the PR body.

Happy to update the validation notes if there is a preferred test command for this module or if maintainers want the fallback precedence adjusted.

@Haarolean

Copy link
Copy Markdown
Member

please explain why you decided to use that property as a fallback? and what's the initial cause why this config entry isn't available/returned by MSK?

@reachsrinivaschennupati-tech

reachsrinivaschennupati-tech commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@Haarolean Thankyou for reviewing this PR.

The reason I used "log.message.format.version" as a fallback is that "inter.broker.protocol.version" is still treated as the primary and preferred source. The fallback only applies when "inter.broker.protocol.version" is not present in the broker config response.

In managed Kafka environments such as MSK, some broker-level settings can be controlled by the service and may not always be exposed through the AdminClient config response the same way they are in a self-managed Kafka cluster. That appears to be the case this change is trying to handle: the primary config is unavailable, but we still need a reasonable version-related signal instead of immediately falling back to "metadata.version" or "Unknown".

"log.message.format.version" is not intended to be a perfect replacement for "inter.broker.protocol.version". I chose it because it is still a Kafka broker compatibility/version-related setting and is commonly considered together with "inter.broker.protocol.version" during Kafka upgrade compatibility handling.

So the precedence remains conservative:

  1. inter.broker.protocol.version
  2. log.message.format.version
  3. metadata.version
  4. Unknown

This means existing behavior is preserved when "inter.broker.protocol.version" is available, and the fallback only improves the MSK case where that config entry is missing.

Please let me know, If you prefer not to infer the displayed Kafka version from "log.message.format.version", I can adjust the PR to keep "metadata.version" as the next fallback instead.

Thanks,
Srinivas

@Haarolean

Copy link
Copy Markdown
Member

This doesn't answer either of my questions.

I asked why MSK doesn't return this config entry — the answer I got is "some broker-level settings may not always be exposed... that appears to be the case this change is trying to handle." You wrote this change; you shouldn't have to guess what case it handles.

Concretely, why this fallback doesn't hold up:

  1. Both inter.broker.protocol.version and log.message.format.version come from the same DescribeConfigs response. If MSK omits one, there's no reason to expect it returns the other — and nothing here demonstrates it does.
  2. log.message.format.version is deprecated since Kafka 3.0 (KIP-724), ignored when IBP >= 3.0, and removed in 4.0. On any current broker it's absent or a meaningless default — strictly worse than the metadata.version fallback we already have, which exists precisely for KRaft clusters (which is what newer MSK runs).
  3. The linked issue (Replace 1.0-UNKNOWN version string with less ambiguous UNKNOWN #831) asks for the 1.0-UNKNOWN label to be changed. The PR doesn't touch that.
  4. The PR body says all tests passed locally; your comment above says gradle was blocked by a Java version mismatch. Both can't be true.

Also, your offer to "adjust the PR to keep metadata.version as the next fallback" describes what's already on main — that adjustment would turn this PR into a no-op.

Happy to reconsider if you can reproduce the issue against a real MSK cluster, post the actual DescribeConfigs/describeFeatures output, and explain the root cause — in your own words.

@kapybro

kapybro Bot commented Jul 31, 2026

Copy link
Copy Markdown

Further user feedback is requested. Please reply within 7 days or we might close the issue.

Signed-off-by: reachsrinivaschennupati-tech <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@reachsrinivaschennupati-tech reachsrinivaschennupati-tech changed the title Use log.message.format.version as fallback for Kafka version in MSK clusters Keep Kafka version fallback on metadata.version Aug 5, 2026
@reachsrinivaschennupati-tech

Copy link
Copy Markdown
Contributor Author

@Haarolean I reworked this based on your feedback.

The PR no longer uses log.message.format.version as a fallback. I also rebased the branch on the latest main, which already keeps the unknown display value as Unknown instead of the old ambiguous label.

What changed now:

  • broker config version extraction only reads the exact inter.broker.protocol.version key
  • metadata.version remains the fallback when the broker config version is unavailable
  • added focused tests showing log.message.format.version is intentionally ignored
  • cleaned up the PR title/body so it no longer claims an unsupported MSK fallback

I attempted the focused Gradle test locally, but this machine only has JDK 17 and the current project build requires source release 25, so Gradle stops at invalid source release: 25. Please review when you have a chance.

@kapybro

kapybro Bot commented Aug 5, 2026

Copy link
Copy Markdown

Thanks for the additional feedback! We'll get back to your issue soon.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/src/main/java/io/kafbat/ui/service/ReactiveAdminClient.java`:
- Around line 197-204: The extractKafkaVersion helper must fall back to
log.message.format.version when no non-null inter.broker.protocol.version value
exists; update it to preserve the preferred-config priority, then update
ReactiveAdminClientVersionTest.java lines 21-38 to cover the missing and null
preferred values and verify the fallback selection.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 34cb1c02-8004-48b9-ad0c-8418c0afe893

📥 Commits

Reviewing files that changed from the base of the PR and between ab8c9ce and 1b9027d.

📒 Files selected for processing (2)
  • api/src/main/java/io/kafbat/ui/service/ReactiveAdminClient.java
  • api/src/test/java/io/kafbat/ui/service/ReactiveAdminClientVersionTest.java

Comment on lines +197 to +204
@VisibleForTesting
static Optional<String> extractKafkaVersion(List<ConfigEntry> configs) {
for (ConfigEntry entry : configs) {
if (entry.name().equals(INTER_BROKER_PROTOCOL_VERSION_CONFIG) && entry.value() != null) {
return Optional.of(entry.value());
}
}
return Optional.empty();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== repo files matching ReactiveAdminClient =="
fd -a 'ReactiveAdminClient|ReactiveAdminClientVersionTest' . || true

echo "== relevant snippets =="
for f in $(fd 'ReactiveAdminClient|ReactiveAdminClientVersionTest' .); do
  echo "--- $f"
  wc -l "$f"
  rg -n "extractKafkaVersion|INTER_BROKER_PROTOCOL_VERSION_CONFIG|LOG_MESSAGE_FORMAT_VERSION|inter.broker.protocol.version|log.message.format.version|kafkaVersion|kafka version" "$f" -C 8 || true
done

echo "== git diff summary/name =="
git diff --stat || true
git diff -- api/src/main/java/io/kafbat/ui/service/ReactiveAdminClient.java api/src/test/java/io/kafbat/ui/service/ReactiveAdminClientVersionTest.java || true

Repository: kafbat/kafka-ui

Length of output: 6387


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== all tracked occurrences of Kafka version config fallback =="
rg -n "log\.message\.format\.version|inter\.broker\.protocol\.version|KafkaVersion|extractKafkaVersion|KafkaVersion::parse|inter.broker.protocol.version|log.message.format.version" . || true

echo "== Behavioral probe: deterministic fallback behavior in source text =="
python3 - <<'PY'
import re
from pathlib import Path

client = Path("api/src/main/java/io/kafbat/ui/service/ReactiveAdminClient.java").read_text()
test = Path("api/src/test/java/io/kafbat/ui/service/ReactiveAdminClientVersionTest.java").read_text()

m = re.search(r"static Optional<String> extractKafkaVersion\(\).*?\n  \}", client, re.S)
method = m.group(0) if m else ""
has_inter_only_return = bool(re.search(r"entry\.name\(\)\.equals\(INTER_BROKER_PROTOCOL_VERSION_CONFIG\)\s*&&\s*entry\.value\(\)\s*!=\s*null", method)) and re.search(r"return Optional\.of\(entry\.value\(\)\);", method)

has_log_fallback = "log.message.format.version" in method or "LOG_MESSAGE_FORMAT_VERSION" in method

test_ignores_log_single = 'new ConfigEntry("log.message.format.version", "3.8-IV0")' in test and 'assertThat(ReactiveAdminClient.extractKafkaVersion(configs)).isEmpty()' in test
test_returns_empty_when_inter_null = 'new ConfigEntry("inter.broker.protocol.version", null)' in test and 'new ConfigEntry("log.message.format.version", "3.8-IV0")' in test and test.endswith('assertThat(ReactiveAdminClient.extractKafkaVersion(configs)).isEmpty();\n}\n')

print({"method_present": bool(m), "inter_broker_only_return": has_inter_only_return, "log_format_or_constant_in_method": has_log_fallback, "test_ignores_log_single": test_ignores_log_single, "test_returns_empty_when_inter_null": test_returns_empty_when_inter_null})
PY

Repository: kafbat/kafka-ui

Length of output: 3336


Restore the stated Kafka version fallback.

extractKafkaVersion(...) only returns inter.broker.protocol.version, so log.message.format.version is ignored even when the preferred config is missing or null. Update the helper and tests to select the log-message format version only after no valid inter-broker value exists.

📍 Affects 2 files
  • api/src/main/java/io/kafbat/ui/service/ReactiveAdminClient.java#L197-L204 (this comment)
  • api/src/test/java/io/kafbat/ui/service/ReactiveAdminClientVersionTest.java#L21-L38
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/src/main/java/io/kafbat/ui/service/ReactiveAdminClient.java` around lines
197 - 204, The extractKafkaVersion helper must fall back to
log.message.format.version when no non-null inter.broker.protocol.version value
exists; update it to preserve the preferred-config priority, then update
ReactiveAdminClientVersionTest.java lines 21-38 to cover the missing and null
preferred values and verify the fallback selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/brokers Broker / broker configs related issues type/bug Something isn't working type/enhancement En enhancement/improvement to an already existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants