-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-13327: Gracefully report connector validation errors instead of returning 500 responses #14303
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
Merged
Merged
KAFKA-13327: Gracefully report connector validation errors instead of returning 500 responses #14303
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ae33a95
KAFKA-13327: Gracefully report connector validation errors instead of…
C0urante 619b714
Remove SinkConnectorConfig::validate variant
C0urante 4491b67
Add comment about skipping validation when class is null
C0urante fd7347a
Tweak error message when DLQ matches topics regex, add newline to end…
C0urante File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value here is null if the class couldn't be loaded, in which case, it's not necessary to try to do any further kind of validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this hides the exception message from "Not a (something)" and only shows the "Missing required configuration (name) which has no default value". I think that is reasonable.
The other call-site for this method is ConnectorConfig.EnrichablePlugin which swallows this error on the validate() code path and propagates them when instantiating the ConnectorConfig. Instantiating the ConnectorConfig will also throw the "Missing required configuration" error, so it is not necessary to throw the error.
I think you could safely change the getConfigDefFromConfigProvidingClass implementation to return an empty stream when the value is null, rather than throwing an exception. I don't think this is necessary, but maybe it keeps these two code paths more similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? It looks like the error swallowing in
ConfigDef.EnrichablePlugin::populateConfigDeftakes place conditionally, and we still do throw exceptions that originate from thegetConfigDefFromConfigProvidingClasssometimes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the condition depends on whether validation is being executed or whether the full ConnectorConfig is being constructed.
I think the other exceptions for non-null classes are fine to leave as-is. I think we could only reasonably change the null-class behavior.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I misread your comment!
I'm hesitant to change the behavior of instantiating a
ConnectorConfigunless it provides a practical, positive impact for users. It doesn't seem significantly cleaner to move the null check either, since guarding against nullClass<?>instances is an inherent necessity of the currentConfigDef.ValidatorAPI (and one that's taken into account with validator classes added in #14304).I've added a comment indicating when we expect
nullvalues in the validator. I'm hopeful that this should be enough to offset the cognitive load added with this change.