You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/06/16 07:44:24 UTC

[GitHub] [apisix-dashboard] yjunsun opened a new issue, #2477: openapi import will panic when requestbody is not empty but with empty content

yjunsun opened a new issue, #2477:
URL: https://github.com/apache/apisix-dashboard/issues/2477

   ### Issue description
   
   When import openapi with apisix-dashboard, the apisix-dashboard service panic and return 500 http state code.
   
   **openapi:**
   ```yaml
   openapi: 3.0.3
   info:
       title: Storage API
       version: 0.0.1
   paths:
       /api/storage/v1/init:
           put:
               tags:
                   - Storage
               operationId: Storage_Init
               requestBody:
                   content:
                       application/json: {}
                   required: true
               responses:
                   "200":
                       description: OK
                       content:
                           application/json:
                               schema:
                                   $ref: '#/components/schemas/InitState'
                   default:
                       description: Default error response
                       content:
                           application/json:
                               schema:
                                   $ref: '#/components/schemas/Status'
   components:
       schemas:
           InitState:
               type: object
               properties:
                   state:
                       type: integer
                       format: enum
           Status:
               type: object
               properties:
                   code:
                       type: integer
                       description: The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
                       format: int32
                   message:
                       type: string
                       description: A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
                   details:
                       type: array
                       items:
                           $ref: '#/components/schemas/GoogleProtobufAny'
                       description: A list of messages that carry the error details.  There is a common set of message types for APIs to use.
               description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).'
   tags:
       - name: Storage
   ```
   
   **ERR LOG:**
   ```log
   err; runtime error: invalid memory address or nil pointer dereference
   [Recovery] 2022/06/16 - 02:36:06 panic recovered:
   
   runtime error: invalid memory address or nil pointer dereference
   /usr/local/go/src/runtime/panic.go:221 (0x449d46)
   /usr/local/go/src/runtime/signal_unix.go:735 (0x449d16)
   /usr/local/apisix-dashboard/api/internal/handler/data_loader/route_import.go:393 (0xc246d9)
   /usr/local/apisix-dashboard/api/internal/handler/data_loader/route_import.go:520 (0xc25344)
   /usr/local/apisix-dashboard/api/internal/handler/data_loader/route_import.go:269 (0xc236a4)
   /usr/local/apisix-dashboard/api/internal/handler/data_loader/route_import.go:341 (0xc23fbd)
   /usr/local/apisix-dashboard/api/internal/handler/data_loader/route_import.go:100 (0xc21bab)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware.go:18 (0x850b2b)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/base.go:16 (0xbf0934)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/traffic_log.go:73 (0xbf0935)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/base.go:16 (0xbee9cd)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/http_input.go:77 (0xbee9ce)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/base.go:16 (0xbf03a2)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/http_resp_reshap.go:19 (0xbf0396)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/base.go:16 (0xbf168e)
   /usr/local/apisix-dashboard/api/internal/handler/handler.go:81 (0xbf1682)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/base.go:16 (0xbee5a1)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/middleware/http_injector.go:28 (0xbee5a2)
   /go/pkg/mod/github.com/shiningrush/droplet@v0.2.6-0.20210127040147-53817015cd1b/pipe.go:84 (0x850e21)
   /go/pkg/mod/github.com/shiningrush/droplet/wrapper/gin@v0.2.1/gin.go:41 (0xbf27be)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xbeb8fd)
   /usr/local/apisix-dashboard/api/internal/filter/authentication.go:81 (0xbeb56a)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xbec10a)
   /usr/local/apisix-dashboard/api/internal/filter/recover.go:53 (0xbec0f4)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xbecf9d)
   /usr/local/apisix-dashboard/api/internal/filter/schema.go:194 (0xbec890)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xbe8dad)
   /usr/local/apisix-dashboard/api/internal/filter/logging.go:35 (0xbe8d94)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xbe8a95)
   /usr/local/apisix-dashboard/api/internal/filter/ip_filter.go:107 (0xbe89e6)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xbec6b6)
   /usr/local/apisix-dashboard/api/internal/filter/request_id.go:41 (0xbec69a)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xbec036)
   /usr/local/apisix-dashboard/api/internal/filter/cors.go:54 (0xbec022)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x9d104c)
   /go/pkg/mod/github.com/gin-contrib/gzip@v0.0.3/handler.go:60 (0x9d1022)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x9c8a84)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:409 (0x9c86b9)
   /go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:367 (0x9c81f3)
   /usr/local/go/src/net/http/server.go:2879 (0x71433a)
   /usr/local/go/src/net/http/server.go:1930 (0x70f9e7)
   /usr/local/go/src/runtime/asm_amd64.s:1581 (0x464c60)
   ```
   
   
   ### Expected behavior
   
   no error
   
   ### How to Reproduce
   
   1. white proto file service like this:
   ```proto
   service XXX (
       rpc Init(google.protobuf.Empty) returns (xxx) {
           option (google.api.http) = {
               put: "/xxx"
               body: "*"
           };
       };
   }
   ```
   
   2. use https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi to generate openapi doc, will like this:
   ```yaml
   paths:
       /xxx:
           put:
               requestBody:
                   content:
                       application/json: {}
                   required: true
   ```
   
   3. import it with apisix-dashboard, you will see 500 error in webpage and a panic log.
   
   ### Screenshots
   
   _No response_
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): apache/apisix:2.14.1-alpine
   - apisix-dashboard version, if have: apache/apisix-dashboard:2.13-alpine
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-dashboard] bzp2010 commented on issue #2477: openapi import will panic when requestbody is not empty but with empty content

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on issue #2477:
URL: https://github.com/apache/apisix-dashboard/issues/2477#issuecomment-1160181218

   Hi, @yjunsun 
   
   Thank you for raising the bug and submitting a fix patch for this, I will review your PR later.
   
   There are a lot of problems with the current OpenAPI import implementation and we are working on improving it, if you want you can help us review the new import implementation.
   You can view the current proposal here, https://github.com/apache/apisix-dashboard/issues/2465. As well as conducting PR reviews #2460 #2474.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-dashboard] yjunsun closed issue #2477: openapi import will panic when requestbody is not empty but with empty content

Posted by GitBox <gi...@apache.org>.
yjunsun closed issue #2477: openapi import will panic when requestbody is not empty but with empty content
URL: https://github.com/apache/apisix-dashboard/issues/2477


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-dashboard] yjunsun commented on issue #2477: openapi import will panic when requestbody is not empty but with empty content

Posted by GitBox <gi...@apache.org>.
yjunsun commented on issue #2477:
URL: https://github.com/apache/apisix-dashboard/issues/2477#issuecomment-1161487741

   > Hi, @yjunsun
   > 
   > Thank you for raising the bug and submitting a fix patch for this, I will review your PR later.
   > 
   > There are a lot of problems with the current OpenAPI import implementation and we are working on improving it, if you want you can help us review the new import implementation. You can view the current proposal here, #2465. As well as conducting PR reviews #2460 #2474, perhaps you can use your use cases to check these new implementations and it will help us to provide a better fit.
   
   It's my pleasure. 
   I'm usually free on weekends.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-dashboard] bzp2010 commented on issue #2477: openapi import will panic when requestbody is not empty but with empty content

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on issue #2477:
URL: https://github.com/apache/apisix-dashboard/issues/2477#issuecomment-1165077432

   ☺️ Haha, the PRs for those codes have been merged into the master branch and the frontend update is almost complete, so maybe you can use your own use OAS cases for testing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org