Schema Violation for config.add headers, expected a string in kong request transformer plugin

After updating from Kong Docker 2.1.4-alpine to 2.2.1-alpine, I noticed some error logs in the console:

W1209 11:47:32.924046       1 queue.go:112] requeuing default/sh.helm.release.v1.myService.v55, err 6 errors occurred:
while processing event: {Update} failed: 400 Bad Request {"message":"schema violation (config.add: {\n  headers = {\n    \"expected a string\"\n  }\n})","name":"schema violation","fields":{"config":{"add":{"headers":["expected a string"]}}},"code":2}
while processing event: {Update} failed: 400 Bad Request {"message":"schema violation (config.add: {\n  headers = {\n    \"expected a string\"\n  }\n})","name":"schema violation","fields":{"config":{"add":{"headers":["expected a string"]}}},"code":2}
while processing event: {Update} failed: 400 Bad Request {"message":"schema violation (config.add: {\n  headers = {\n    \"expected a string\"\n  }\n})","name":"schema violation","fields":{"config":{"add":{"headers":["expected a string"]}}},"code":2}
while processing event: {Update} failed: 400 Bad Request {"message":"schema violation (config.add: {\n  headers = {\n    \"expected a string\"\n  }\n})","name":"schema violation","fields":{"config":{"add":{"headers":["expected a string"]}}},"code":2}
while processing event: {Update} failed: 400 Bad Request {"message":"schema violation (config.add: {\n  headers = {\n    \"expected a string\"\n  }\n})","name":"schema violation","fields":{"config":{"add":{"headers":["expected a string"]}}},"code":2}
while processing event: {Update} failed: 400 Bad Request {"message":"schema violation (config.add: {\n  headers = {\n    \"expected a string\"\n  }\n})","name":"schema violation","fields":{"config":{"add":{"headers":["expected a string"]}}},"code":2}

We are using the request-transformer plugin to do something like this:

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
plugin: request-transformer
metadata:
  name: myService-rq
config:
  add:
    headers:
      - WebApiKey:myWebApiKey

The error log mentions that there is a schema violation and headers are expected to be a string, which does not seem to be the case looking at the official examples here.

config:
  add:
    headers:
    - x-new-header:value
    - x-another-header:something

In some cases this even happens when there is no request transformer and we are not adding any config.add.headers using the plugin.

Has anyone experienced the same problems? Do you have any Idea what I could do to fix this?

Thanks for your support! :wink:

We also face the same problem, configuration won’t support any special character, we are using . like route.regex_priority: return null in another plugin.

for those stumbling on this, encountered the same issue. In my case the issue was resolved by ensuring that there are no spaces between the header key and value. This was specifically causing problems as I was interpreting from a k8s secret (which is not a particularly well-documented use case)

# secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: request-transformer-add-api-key-secret
  namespace: mynamespace
type: Opaque
stringData:
    HEADER_CONFIG: |
      add:
        headers:
        - api-key:no-space-before-me # note how there's not space after colon

and then the plugin

# plugin.yaml
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: request-transformer-add-api-key-secret-plugin
  namespace: mynamespace
plugin: request-transformer
configFrom:
  secretKeyRef:
     name: request-transformer-add-api-key-secret
     key: HEADER_CONFIG