Revert "Fix unhandled exception in KafkaIO SDF (#37449)"#38361
Revert "Fix unhandled exception in KafkaIO SDF (#37449)"#38361johnjcasey merged 1 commit intomasterfrom
Conversation
|
@junaiddshaukat unfortunately it looks like your change caused some precommit failures elsewhere, so I'm reverting it for now. @acrites thanks for finding |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request reverts a previous change that introduced soft logging for missing Kafka topics. The intent is to enforce stricter validation by throwing an exception when partition information cannot be retrieved, preventing silent failures in KafkaIO pipelines. This change ensures that misconfigured topics are identified during the pipeline execution rather than being ignored. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request modifies the Kafka topic partition verification logic in KafkaIO and WatchForKafkaTopicPartitions, transitioning from warning-based logging to strict state checks using checkState. In WatchForKafkaTopicPartitions, the logger was removed entirely in favor of these checks, and associated tests were deleted. However, the implementation in KafkaIO.java contains a logic error where the warning block executes regardless of partition validity when logTopicVerification is enabled, and the removal of the continue statement will lead to a NullPointerException if partitions are missing.
| if (logTopicVerification == null || !logTopicVerification) { | ||
| checkState( | ||
| partitionInfoList != null && !partitionInfoList.isEmpty(), | ||
| "Could not find any partitions info for topic %s. Please check Kafka configuration and make sure that provided topics exist.", | ||
| topic); | ||
| } else { | ||
| LOG.warn( | ||
| "Could not find any partitions info for topic {}. Please check Kafka " | ||
| + "configuration and make sure that the provided topics exist.", | ||
| "Could not find any partitions info for topic {}. Please check Kafka configuration " | ||
| + "and make sure that the provided topics exist.", | ||
| topic); | ||
| continue; | ||
| } |
There was a problem hiding this comment.
The logic in this revert is incorrect. If logTopicVerification is true, the else block executes for every topic, logging a warning even when partitionInfoList is valid. Furthermore, if partitionInfoList is null, the code will proceed to the loop at line 2145 and throw a NullPointerException because the continue statement was removed. The warning and skip logic should only trigger if partitionInfoList is actually null or empty.
| if (logTopicVerification == null || !logTopicVerification) { | |
| checkState( | |
| partitionInfoList != null && !partitionInfoList.isEmpty(), | |
| "Could not find any partitions info for topic %s. Please check Kafka configuration and make sure that provided topics exist.", | |
| topic); | |
| } else { | |
| LOG.warn( | |
| "Could not find any partitions info for topic {}. Please check Kafka " | |
| + "configuration and make sure that the provided topics exist.", | |
| "Could not find any partitions info for topic {}. Please check Kafka configuration " | |
| + "and make sure that the provided topics exist.", | |
| topic); | |
| continue; | |
| } | |
| if (logTopicVerification == null || !logTopicVerification) { | |
| checkState( | |
| partitionInfoList != null && !partitionInfoList.isEmpty(), | |
| "Could not find any partitions info for topic %s. Please check Kafka configuration and make sure that provided topics exist.", | |
| topic); | |
| } else if (partitionInfoList == null || partitionInfoList.isEmpty()) { | |
| LOG.warn( | |
| "Could not find any partitions info for topic {}. Please check Kafka configuration " | |
| + "and make sure that the provided topics exist.", | |
| topic); | |
| continue; | |
| } |
okay np, should i need to make a new pr for #37449. or just leave it for now |
Reverts #37553
This stops using a flag, but doesn't clean the flag up or cleans up the tests that depend on the flag. While merged, it causes precommit failures for other PRs.
TODO clean up the dangling reference, and the tests: https://github.com/apache/beam/blob/master/sdks/java/io/kafka/src/test/java/org/apache/beam/sdk/io/kafka/KafkaIOIT.java#L290, and others