-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
KAFKA-4372: Kafka Connect REST API does not handle DELETE of connector with slashes in their names #2096
KAFKA-4372: Kafka Connect REST API does not handle DELETE of connector with slashes in their names #2096
Conversation
Even though the rest of the API points accept connector names containing slashes
Added a BadRequestException if someone tries to create one like that and added unit test to check that
The test failures do not seem to be related to the PR |
@@ -89,6 +89,9 @@ public ConnectorsResource(Herder herder) { | |||
public Response createConnector(final @QueryParam("forward") Boolean forward, | |||
final CreateConnectorRequest createRequest) throws Throwable { | |||
String name = createRequest.name(); | |||
if (name.contains("/")){ |
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.
nit: missing whitespace between (}
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.
fixed
@@ -89,6 +89,9 @@ public ConnectorsResource(Herder herder) { | |||
public Response createConnector(final @QueryParam("forward") Boolean forward, | |||
final CreateConnectorRequest createRequest) throws Throwable { | |||
String name = createRequest.name(); | |||
if (name.contains("/")) { | |||
throw new BadRequestException("connector name should not contain '/'"); |
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.
I believe connectors can also be created via putConnectorConfig()
below, PUT additionally allows for 'replace' while that is not allowed for this endpoint. So for consistency I think we should either disallow it in both places or neither.
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.
well the PUT API takes a PathParam so it won't allow for a slash in the connector name. I agree it is not explicit but no connector with a slash in its name can be PUT
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.
Got it, make sense.
LGTM cc @ewencp or @hachikuji for review |
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.
One minor style issue, but LGTM. We might want to eventually refactor so this is reusable (and since we may find other constraints we want to enforce, but given current usage I think its fine to leave inline like this for now.
@@ -194,6 +194,23 @@ public void testCreateConnectorExists() throws Throwable { | |||
PowerMock.verifyAll(); | |||
} | |||
|
|||
@Test(expected = BadRequestException.class) | |||
public void testCreateConnectorWithASlashInItsName() throws Throwable { | |||
String badConnectorName = CONNECTOR_NAME+"/"+"test"; |
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.
This doesn't pass checkstyle -- you need spaces before and after the +
.
Fixed code styling in tests too |
LGTM, thanks! |
thx |
Kafka Connect REST API does not handle in many places connectors with slashes in their names because it expects PathParams, this PR intends to :
This PR adds as well the Unit Test needed for the creation part and was tested manually for the DELETE part.