Skip to content

bug: Cannot create a Service with an ID as a string? #1654

@shibingli

Description

@shibingli

Issue description

Create a Service with a custom ID. Cannot create a Service with an ID as a string

ex:

/apisix/admin/services/{id} //id-> 5ed8b4902b0b28f6b3b4e0a4
/apisix/admin/services/5ed8b4902b0b28f6b3b4e0a4

But if you create Upstream, the ID will be a string

Environment

  • apisix version (cmd: apisix version): 1.3
  • OS: Linux (Fedora 32 WS)

Minimal test code / Steps to reproduce the issue

1、curl -s http://127.0.0.1:9080/apisix/admin/services/5ed8b4902b0b28f6b3b4e0a4 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -i -X PUT -d '{"desc":"hello world","upstream_id":"5ed77d7ba565f16210f76fcd"}' | awk 'END {print}' | jq .

What's the actual result? (including assertion message & call stack if applicable)

{
"error_msg": "wrong type of service id"
}

What's the expected result?

You can create a resource as an ID of the string type

    if need_id and not tonumber(id) then
        return nil, {error_msg = "wrong type of service id"}
    end

tonumber ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions