Skip to content

KAFKA-19459: List internal topics for the user #20157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

lucliu1108
Copy link

For the Kafka Stream group commands, if delete topic requests fail due to version mismatch, user will have to remove the topics manually by first retrieving the relevant internal topics.

To assist the user, the internal topic names are now included as part of the error message, so that the user could delete the internal topics associated with this application directly.

Reviewer: @aliehsaeedii

@github-actions github-actions bot added triage PRs from the community tools small Small PRs labels Jul 11, 2025
Copy link
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

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

@lucliu1108: Thanks for the patch.

Comment on lines 849 to 850
printError("Retrieving internal topics is not supported by the broker version. " +
"Use 'kafka-topics.sh' to list and delete the group's internal topics.", Optional.of(e.getCause()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we combine the internal topics message into printError?

Comment on lines 834 to 845
List<String> internalTopics = new ArrayList<>();
try {
Set<String> allTopics = adminClient.listTopics().names().get();
for (String topic : allTopics) {
for (String groupId : groupIds) {
if (isInferredInternalTopic(topic, groupId)) {
internalTopics.add(topic);
break;
}
}
}
System.out.println("Internal Topics: (" + String.join(",", internalTopics) + ").");
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use the stream api to align the style with this whole class.
For example:

Suggested change
List<String> internalTopics = new ArrayList<>();
try {
Set<String> allTopics = adminClient.listTopics().names().get();
for (String topic : allTopics) {
for (String groupId : groupIds) {
if (isInferredInternalTopic(topic, groupId)) {
internalTopics.add(topic);
break;
}
}
}
System.out.println("Internal Topics: (" + String.join(",", internalTopics) + ").");
String internalTopics;
try {
Set<String> allTopics = adminClient.listTopics().names().get();
internalTopics = allTopics.stream()
.filter(topic -> groupIds.stream().anyMatch(groupId -> isInferredInternalTopic(topic, groupId)))
.collect(Collectors.joining(","));
System.out.println("Internal Topics: (" + internalTopics + ").");

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the comment! Just revised the method:

  1. use Stream API
  2. Combine print internal topics in the printError message.

@github-actions github-actions bot removed the triage PRs from the community label Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants