redpanda-data / redpanda

Redpanda is a streaming data platform for developers. Kafka API compatible. 10x faster. No ZooKeeper. No JVM!
https://redpanda.com
9.46k stars 579 forks source link

Schema registry wrong response on DELETE /config/<subject> #19863

Closed nicolaferraro closed 3 months ago

nicolaferraro commented 3 months ago

Version & Environment

Redpanda version: (use rpk version): v24.1.2

What went wrong?

Running a HTTP Delete towards the config/<subject> endpoint fails if the content-type is not specified (but the body is expected to be empty). It also returns a response slightly different from the Kafka schema registry.

See:

$ curl -H "content-type: application/json" -i -X PUT -d '{"compatibility": "NONE"}' http://localhost:8072/config/example
HTTP/1.1 200 OK
Content-Length: 24
Content-Type: application/vnd.schemaregistry.v1+json
Date: Mon, 17 Jun 2024 16:40:55 GMT
Server: Seastar httpd

{"compatibility":"NONE"}

$ curl -i -X DELETE http://localhost:8072/config/example
HTTP/1.1 415 Unsupported Media Type
Content-Length: 53
Server: Seastar httpd
Date: Mon, 17 Jun 2024 16:41:32 GMT
Content-Type: application/vnd.schemaregistry.v1+json

{"error_code":415,"message":"unsupported_media_type"}

$ curl -H "content-type: application/json" -i -X DELETE http://localhost:8072/config/example
HTTP/1.1 200 OK
Content-Length: 29
Content-Type: application/vnd.schemaregistry.v1+json
Date: Mon, 17 Jun 2024 16:42:00 GMT
Server: Seastar httpd

{"compatibilityLevel":"NONE"}

What should have happened instead?

  1. It should have ignored content-type, since the DELETE request is not expecting a body
  2. The correct response should have been the following:
{"compatibility":"NONE"}

I.e. compatibility instead of compatibilityLevel, as we correctly state in the API schema:

        "produces": ["application/vnd.schemaregistry.v1+json"],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/put_compatibility"
            }
          }

(put_compatibility instead of get_compatibility).

See also https://docs.confluent.io/platform/current/schema-registry/develop/api.html#delete--config-(string-%20subject).

How to reproduce the issue?

  1. Follow the script above.

JIRA Link: CORE-4204

BenPope commented 3 months ago

For 2. the docs are incorrect. The behaviour is compatible.

nicolaferraro commented 3 months ago

Yeah, we should update our openAPI spec

BenPope commented 3 months ago

Fixed by https://github.com/redpanda-data/redpanda/pull/19866