Skip to content
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

Plugin schema inconsistentcy for request-transformer #4137

Closed
hbagdi opened this issue Dec 28, 2018 · 1 comment
Closed

Plugin schema inconsistentcy for request-transformer #4137

hbagdi opened this issue Dec 28, 2018 · 1 comment
Milestone

Comments

@hbagdi
Copy link
Member

hbagdi commented Dec 28, 2018

Summary

Plugin schema for request transformer contains fields in a nested object as opposed to an array.

Steps To Reproduce

http :8001/plugins/schema/request-transformer
-- stripped out  
      {
            "remove": {
                "fields": {
                    "1": {
                        "body": {
                            "default": {},
                            "elements": {
                                "type": "string"
                            },
                            "type": "array"
                        }
                    },
                    "2": {
                        "headers": {
                            "default": {},
                            "elements": {
                                "type": "string"
                            },
                            "type": "array"
                        }
                    },
                    "3": {
                        "querystring": {
                            "default": {},
                            "elements": {
                                "type": "string"
                            },
                            "type": "array"
                        }
                    },
                    "body": {
                        "default": {},
                        "elements": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "headers": {
                        "default": {},
                        "elements": {
                            "type": "string"
                        },
                        "type": "array"
                    },
                    "querystring": {
                        "default": {},
                        "elements": {
                            "type": "string"
                        },
                        "type": "array"
                    }
                },
                "required": true,
                "type": "record"
            }
        },
-- stripped out

The fields property of schema of an object should be an array and not an object.
Also, as can be seen, the fields are again nested into 1, 2, 3, and are also present in the fields object itself, which seems ambiguous.

Additional Details & Logs

  • Kong version ($ kong version) 1.0.0
  • Kong debug-level startup logs ($ kong start --vv)
  • Kong error logs (<KONG_PREFIX>/logs/error.log) none
  • Operating system Ubuntu
@hbagdi
Copy link
Member Author

hbagdi commented Jan 3, 2019

There is another bug that I ran into, I'm not opening up a separate issue, if it's better to do so, let me know.

http :8001/plugins/schema/prometheus
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 13
Content-Type: application/json; charset=utf-8
Date: Thu, 03 Jan 2019 19:19:06 GMT
Server: kong/1.0.0

{
    "fields": {}
}

The empty fields should be an array.

hishamhm added a commit that referenced this issue Jan 7, 2019
* Ensure that plugin schemas return sub-fields of nested records in the same
  format as the toplevel `fields` entry (i.e., as an array of single-fields
  objects, so that the field order can be retrieved).
* Ensure `fields` in `/plugins/schema` always returns a JSON array,
  even when it is empty (as in the prometheus plugin).

This produces an incompatible output from that of 1.0.0, but the one in
1.0.0 is arguably broken, so this produces the intended result.

Fixes #4137.
thibaultcha pushed a commit that referenced this issue Jan 7, 2019
* Ensure that plugin schemas return sub-fields of nested records in the same
  format as the toplevel `fields` entry (i.e., as an array of single-fields
  objects, so that the field order can be retrieved).
* Ensure `fields` in `/plugins/schema/:plugin` always returns a JSON array,
  even when it is empty (as in the prometheus plugin).

This produces an incompatible output from that of 1.0.0, but the one in
1.0.0 is arguably broken, so this produces the intended result.

Fix #4137
From #4162
@hishamhm hishamhm added this to the 1.0.1 milestone Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants