Skip to content

bug: APISIX core resources require strict verification and do not need to pass in additional fields. #10229

Description

@Sn0rt

the original PR #4797

Current Behavior

# curl http://127.0.0.1:9180/apisix/admin/routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -d '{
                       "upstream": {
                           "type": "roundrobin",
                           "nodes": {
                               "httpbin.org": 1
                           },
                           "vvv": "ccc"
                       },
                       "uri": "/get"
                   }'
                   
{"key":"/apisix/routes/00000000000000013083","value":{"upstream":{"type":"roundrobin","scheme":"http","pass_host":"pass","nodes":{"httpbin.org":1},"hash_on":"vars","vvv":"ccc"},"id":"00000000000000013083","status":1,"create_time":1694071341,"uri":"/get","update_time":1694071341,"priority":0}}
# etcdctl get /apisix/routes/00000000000000013083

/apisix/routes/00000000000000013083
{"id":"00000000000000013083","priority":0,"update_time":1694071341,"create_time":1694071341,"uri":"/get","status":1,"upstream":{"type":"roundrobin","scheme":"http","pass_host":"pass","nodes":{"httpbin.org":1},"hash_on":"vars","vvv":"ccc"}}

Expected Behavior

No additional fields can be passed in core resources.

Core resources include

  • Consumer
  • Consumer Group
  • Global Rules
  • Plugin
  • Plugin Config
  • Route
  • stream route
  • Service
  • Upstream

Error Logs

N/A

Steps to Reproduce

N/A

Environment

  • APISIX version (run apisix version): master
  • Operating system (run uname -a): ubuntu
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

If the user uses the service discovery function of APISIX such as nacos, the definition of upstream needs to be updated.

--- config
    location /t {
        content_by_lua_block {
            local t = require("lib.test_admin").test
            local code, body = t('/apisix/admin/upstreams',
                 ngx.HTTP_PUT,
                 [[{
                    "id": 1,
                    "nodes": {
                        "127.0.0.1:8080": 1
                    },
                    "type": "roundrobin",
                    "_service_name": "xyz",
                    "_discovery_type": "nacos"
                }]]
            )

            ngx.status = code
            ngx.say(body)
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions