Skip to content

file-log curl examples wrong? #4066

Open
@rkazak

Description

@rkazak

Where is the problem?

https://docs.konghq.com/hub/kong-inc/file-log/#custom-fields-by-lua

What happened?

I followed the given example

Test2 /Users/rkazak >curl -i -X POST --url http://localhost:28001/plugins/bd4b169a-9547-4135-b023-d1cc86f38542 --data config.custom_fields_by_lua.route="return nil"

which resulted in

HTTP/1.1 405 Not Allowed
Date: Tue, 28 Jun 2022 01:13:07 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: http://localhost:28002
X-Kong-Admin-Request-ID: W59MIMJYRXIaryjMLwdtMzU12rmDj2sR
vary: Origin
Access-Control-Allow-Credentials: true
Content-Length: 32
X-Kong-Admin-Latency: 0
Server: kong/2.8.1.1-enterprise-edition

{"message":"Method not allowed"}%

What did you expect to happen?

Plugin to be updated with new settings.

We can achieve what we want with

Test2 /Users/rkazak >curl -i -X PATCH --url http://localhost:28001/plugins/bd4b169a-9547-4135-b023-d1cc86f38542 --data config.custom_fields_by_lua.route="return nil"

Which resulted in

HTTP/1.1 200 OK
Date: Tue, 28 Jun 2022 01:13:34 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: http://localhost:28002
X-Kong-Admin-Request-ID: hLM3wAFwhk6wIv0TK2rPXiD0F3CPcdo5
vary: Origin
Access-Control-Allow-Credentials: true
Content-Length: 306
X-Kong-Admin-Latency: 15
Server: kong/2.8.1.1-enterprise-edition

{"consumer":null,"protocols":["grpc","grpcs","http","https"],"enabled":true,"config":{"reopen":false,"custom_fields_by_lua":{"route":"return nil"},"path":"/tmp/file.log"},"created_at":1656378281,"id":"bd4b169a-9547-4135-b023-d1cc86f38542","tags":["g-f-l-p-0"],"route":null,"name":"file-log","service":null}%

As an aside, I did try PUT but that requires the whole object to be defined ( I think ). For completeness

Test2 /Users/rkazak >curl -i -X PUT --url http://localhost:28001/plugins/bd4b169a-9547-4135-b023-d1cc86f38542 --data config.custom_fields_by_lua.route="return nil"

Which resulted in

HTTP/1.1 400 Bad Request
Date: Tue, 28 Jun 2022 01:13:16 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: http://localhost:28002
X-Kong-Admin-Request-ID: erdIUqSkfZniU8fFLgvHMCSleU7gAeDm
vary: Origin
Access-Control-Allow-Credentials: true
Content-Length: 139
X-Kong-Admin-Latency: 2
Server: kong/2.8.1.1-enterprise-edition

{"message":"schema violation (name: required field missing)","code":2,"name":"schema violation","fields":{"name":"required field missing"}}%

Code of Conduct and Community Expectations

  • I agree to follow this project's Code of Conduct
  • I agree to abide by the Community Expectations

Metadata

Metadata

Assignees

No one assigned

    Labels

    review:generalReview for general accuracy and presentation. Does the doc work? Does it output correctly?review:techRequest for technical review on the docs platform or processes.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions