You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by Gantigmaa Selenge1 <Ga...@uk.ibm.com> on 2022/04/29 15:45:10 UTC

Connect API returns an inconsistent return code

Hello,

I would like to clarify if the following is an expected behaviour.

Connect API returns 500 in the response when creating a connector that already exists or deleting a connector that does not exist. E.g.
```
curl -X DELETE https://localhost:8443/connectors/MirrorSourceConnector
{
  "error_code": 500,
  "message": "Error trying to forward REST request: Connector MirrorSourceConnector not found"
}

```
The API code seem to return 409 for the create call and 404 for the delete call in these cases but the REST client throws new exception with 500 for any response code that is above 400.

https://github.com/apache/kafka/blob/trunk/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java#L147

However, when sending a GET request to the API for a connector that does not exist, it returns 404 in the response. It seemed like a bit of an inconsistent behaviour of connect API, so I just wanted to clarify.



Unless otherwise stated above:

IBM United Kingdom Limited
Registered in England and Wales with number 741598
Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU

Re: Connect API returns an inconsistent return code

Posted by Mickael Maison <mi...@gmail.com>.
Hi Tina,

Yes this is a bug. There's already a JIRA for it:
https://issues.apache.org/jira/browse/KAFKA-13702

Thanks,
Mickael

On Fri, Apr 29, 2022 at 5:45 PM Gantigmaa Selenge1
<Ga...@uk.ibm.com> wrote:
>
> Hello,
>
> I would like to clarify if the following is an expected behaviour.
>
> Connect API returns 500 in the response when creating a connector that already exists or deleting a connector that does not exist. E.g.
> ```
> curl -X DELETE https://localhost:8443/connectors/MirrorSourceConnector
> {
>   "error_code": 500,
>   "message": "Error trying to forward REST request: Connector MirrorSourceConnector not found"
> }
>
> ```
> The API code seem to return 409 for the create call and 404 for the delete call in these cases but the REST client throws new exception with 500 for any response code that is above 400.
>
> https://github.com/apache/kafka/blob/trunk/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestClient.java#L147
>
> However, when sending a GET request to the API for a connector that does not exist, it returns 404 in the response. It seemed like a bit of an inconsistent behaviour of connect API, so I just wanted to clarify.
>
>
>
> Unless otherwise stated above:
>
> IBM United Kingdom Limited
> Registered in England and Wales with number 741598
> Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU