Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when using API gateway #22

Closed
vaughany opened this issue Jul 10, 2023 · 16 comments
Closed

Panic when using API gateway #22

vaughany opened this issue Jul 10, 2023 · 16 comments

Comments

@vaughany
Copy link

Hi there. Wiretap is panicing when I attempt to access the API gateway URL. I am running version 0.0.18 on Linux x86-64 bit.

I invoked the program with:

wiretap --spec specs/specification.yaml  --url https://the-live-domain-in-the-specification.com

Wiretap starts up as expected with:

 INFO  API Gateway UI booting on port 9090...
 INFO  Monitor UI booting on port 9091...
INFO [ranch] Yee-Haw! Starting up the ranch's HTTP server at localhost:9092  fileName=server.go goroutine=66 package=server
INFO [ranch] Hot-Dang! Starting up the ranch's STOMP message broker at localhost:9092/ranch  fileName=server.go goroutine=67 package=server

┌─ wiretap is online! ─────────────────────────────────────┐
|                                                          |
|   ┌─ API Gateway ─────────┐ ┌─ Monitor UI ──────────┐    |
|   | http://localhost:9090 | | http://localhost:9091 |    |
|   └───────────────────────┘ └───────────────────────┘    |
|                                                          |
└──────────────────────────────────────────────────────────┘

Accessing http://localhost:9091/ gives me the below page:

image

However, accessing http://localhost:9090/ results in an error:

This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE

...and in the terminal:

2023/07/10 12:31:02 http: panic serving [::1]:45744: runtime error: invalid memory address or nil pointer dereference
goroutine 156 [running]:
net/http.(*conn).serve.func1()
        /opt/hostedtoolcache/go/1.20.5/x64/src/net/http/server.go:1854 +0xbf
panic({0xab69e0, 0x17335b0})
        /opt/hostedtoolcache/go/1.20.5/x64/src/runtime/panic.go:890 +0x263
github.com/pb33f/wiretap/daemon.(*WiretapService).handleHttpRequest(0xc000098500, 0xc000510540)
        /home/runner/work/wiretap/wiretap/daemon/handle_request.go:102 +0x6d6
github.com/pb33f/wiretap/daemon.(*WiretapService).HandleHttpRequest(...)
        /home/runner/work/wiretap/wiretap/daemon/wiretap_service.go:78
github.com/pb33f/wiretap/cmd.handleHttpTraffic.func1.1({0x12c1cc0?, 0xc0004c4410}, 0xc0005d8000)
        /home/runner/work/wiretap/wiretap/cmd/handle_http_traffic.go:27 +0xe5
net/http.HandlerFunc.ServeHTTP(0xc000600000?, {0x12c1cc0?, 0xc0004c4410?}, 0xc000589950?)
        /opt/hostedtoolcache/go/1.20.5/x64/src/net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0xc0005120c0?, {0x12c1cc0, 0xc0004c4410}, 0xc0005d8000)
        /opt/hostedtoolcache/go/1.20.5/x64/src/net/http/server.go:2500 +0x149
github.com/gorilla/handlers.CompressHandlerLevel.func1({0x12c2650, 0xc00014e000}, 0xc0005d8000)
        /home/runner/go/pkg/mod/github.com/gorilla/handlers@v1.4.2/compress.go:148 +0x9e8
net/http.HandlerFunc.ServeHTTP(0x0?, {0x12c2650?, 0xc00014e000?}, 0x46a56e?)
        /opt/hostedtoolcache/go/1.20.5/x64/src/net/http/server.go:2122 +0x2f
net/http.serverHandler.ServeHTTP({0xc00051e2a0?}, {0x12c2650, 0xc00014e000}, 0xc0005d8000)
        /opt/hostedtoolcache/go/1.20.5/x64/src/net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc00044a120, {0x12c2bc0, 0xc00051e420})
        /opt/hostedtoolcache/go/1.20.5/x64/src/net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
        /opt/hostedtoolcache/go/1.20.5/x64/src/net/http/server.go:3089 +0x5ed
@daveshanley
Copy link
Member

This is a silly bug introduced by me, rushing another feature out of the door, breaking the base use-case of the tool. I apologize for this!

Breaking my own rules of high quality. It's been fixed in v0.0.19, which is running through the pipeline now.

@daveshanley
Copy link
Member

Resolved in v0.0.19

@LegendWojciechPolowniak

Hey, thanks for the tool - it's really promising! I'm using 0.0.20 now, using defaults, and I too am gettic a panic:

INFO [wiretap] request /v1.0/sessions: completed (200)  fileName=handle_request.go goroutine=500 package=daemon
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x567aa0]

goroutine 48 [running]:
github.com/pb33f/libopenapi-validator/responses.ValidateResponseSchema(0x4000bfa200, 0x4000b0c2d0, 0x4000cc2c80, {0x40003e2000, 0xb05, 0xc00}, {0x40007d6b00, 0x53a, 0x4000a5c0f0?})
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.8/responses/validate_response.go:100 +0x730
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).checkResponseSchema(0x4000cc6440, 0x4000be64b0?, 0x4000ac0440?, {0x4000ac0440?, 0x1?}, 0x4000a45d80)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.8/responses/validate_body.go:147 +0x224
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).ValidateResponseBody(0x4000cc6440, 0x4000bfa200, 0x4000b0c2d0)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.8/responses/validate_body.go:53 +0x514
github.com/pb33f/wiretap/daemon.(*WiretapService).validateResponse(0x40000f8b00, 0x40005a2600, {0xe29008?, 0x4000cc6440?}, 0x4000b0c000?)
        /home/runner/work/wiretap/wiretap/daemon/validate.go:24 +0x64
created by github.com/pb33f/wiretap/daemon.(*WiretapService).handleHttpRequest
        /home/runner/work/wiretap/wiretap/daemon/handle_request.go:168 +0xa1c

If that's not enough I can try to provide some basic OAS file to test against it. I'm running the app on Apple Silicon inside a docker container

@LegendWojciechPolowniak

If that makes debugging stuff any easier, after crash this is what I receive in the web monitor:
image

Note the NaNms, and there is also no insights about the request/response in the respective tabs

@daveshanley daveshanley reopened this Jul 19, 2023
@daveshanley
Copy link
Member

Thank you for finding this! and thank you for being an early tester.

If you could supply the openapi spec, it would be super helpful, thank you!

Also the reason the UI is messed up, is because the response never came in and the UI does not know how to handle it yet, than you for finding this.

@LegendWojciechPolowniak

Sure! I'm going to be off for a week and I don't think I'll make it before I leave, but I'll try to provide you with some simplified reproduction file :)

@LegendWojciechPolowniak
Copy link

LegendWojciechPolowniak commented Jul 21, 2023

  openapi: 3.0.0
paths:
  /v1.0/sessions:
    get:
      operationId: SomeID
      summary: XXX
      description: >-
        XXX
      parameters:
        - name: order
          required: false
          in: query
          schema:
            default: ASC
            enum:
              - ASC
              - DESC
            type: string
        - name: sort
          required: false
          in: query
          schema:
            default: id
            enum:
              - createdAt
              - updatedAt
              - id
              - someId2
              - someId3
              - someId1
              - someId4
              - someId5
              - propertyX
              - propertyL
              - propertyC
              - propertyT
              - connectionTime
              - terminated
            type: string
        - name: pageNumber
          required: false
          in: query
          description: Integer representing a page number to show
          examples:
            "1":
              value: 1
            "2":
              value: 2
            "3":
              value: 3
            "4":
              value: 4
            "5":
              value: 5
          schema:
            minimum: 1
            format: int32
            default: 1
            type: number
        - name: pageSize
          required: false
          in: query
          description: Integer representing a size of a single page
          examples:
            "1":
              value: 1
            "5":
              value: 5
            "10":
              value: 10
            "20":
              value: 20
            "50":
              value: 50
          schema:
            minimum: 1
            maximum: 50
            format: int32
            default: 10
            type: number
        - name: environment
          required: false
          in: query
          description: filter environment params
          style: deepObject
          explode: true
          schema:
            $ref: "#/components/schemas/SessionEnvironmentFilterDto"
        - name: period
          required: false
          in: query
          description: filters sessions by connectionTime
          style: deepObject
          explode: true
          schema:
            $ref: "#/components/schemas/SessionsFromPeriodFilterDto"
      responses:
        "200":
          description: Successfully received session list
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/PageDto"
                  - properties:
                      results:
                        type: array
                        items:
                          $ref: "#/components/schemas/SessionDto"
        2XX: &a5
          description: ""
        3XX: &a6
          description: ""
        4XX: &a7
          description: ""
      tags: &a8
        - Sessions
info:
  title: XXX
  description: >-
    ### XXX
  version: 1.3.0
  contact:
    name: Wojtek Połowniak
    url: ""
    email: wojciech.polowniak@mail.com
tags: []
servers:
  - url: https://server.local
components:
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
  schemas:
    SessionsFromPeriodFilterDto:
      type: object
      properties:
        from:
          type: string
          description: ISO Date
          examples: &a42
            2023-07-20T12:04:48.141Z:
              value: 2023-07-20T12:04:48.141Z
            2023-02-20T12:04:48.141Z:
              value: 2023-02-20T12:04:48.141Z
          format: date-time
        to:
          type: string
          description: ISO Date
          examples: *a42
          format: date-time
    SessionEnvironmentFilterDto:
      type: object
      properties:
        propertyX:
          type: string
          description: Alpha-2 representation of the country of origin
          examples: &a46
            NZ:
              value: NZ
            PL:
              value: PL
            US:
              value: US
            GB:
              value: GB
            DE:
              value: DE
        someId2:
          type: number
          description:  some id 2
          format: int32
          examples: &a43
            "15":
              value: 15
            "21":
              value: 21
            "24":
              value: 24
        brandId:
          type: number
          description:  someId4
          format: int32
          examples: &a45
            "15":
              value: 15
            "21":
              value: 21
            "24":
              value: 24
        someId1:
          type: number
          description:   id
          format: int32
          examples: &a44
            "15":
              value: 15
            "21":
              value: 21
            "24":
              value: 24
    PageMetaDto:
      type: object
      properties:
        pageNumber:
          type: number
          description: Integer representing a page number to show
          examples:
            "1":
              value: 1
            "2":
              value: 2
            "3":
              value: 3
            "4":
              value: 4
            "5":
              value: 5
          format: int32
          minimum: 1
          default: 1
        pageSize:
          type: number
          description: Integer representing a size of a single page
          examples:
            "1":
              value: 1
            "5":
              value: 5
            "10":
              value: 10
            "20":
              value: 20
            "50":
              value: 50
          format: int32
          minimum: 1
          maximum: 50
          default: 10
        itemCount:
          type: number
          description: Integer representing a total number of items
          examples:
            "0":
              value: 0
            "2":
              value: 2
            "120":
              value: 120
            "523":
              value: 523
            "765":
              value: 765
          format: int32
        pageCount:
          type: number
          description: Integer representing a total number of pages
          examples:
            "1":
              value: 1
            "2":
              value: 2
            "3":
              value: 3
            "4":
              value: 4
            "324":
              value: 324
          format: int32
        hasPreviousPage:
          type: boolean
          description: Boolean representing whether there is a previous page relative to
            the current one
          examples:
            "true":
              value: true
            "false":
              value: false
          format: int32
        hasNextPage:
          type: boolean
          description: Boolean representing whether there is a next page relative to the
            current one
          examples:
            "true":
              value: true
            "false":
              value: false
          format: int32
      required:
        - pageNumber
        - pageSize
        - itemCount
        - pageCount
        - hasPreviousPage
        - hasNextPage
    PageDto:
      type: object
      properties:
        results:
          type: array
          items:
            type: array
        meta:
          $ref: "#/components/schemas/PageMetaDto"
      required:
        - results
        - meta
    SessionDto:
      type: object
      properties:
        socketId:
          type: string
          description: Socket.io client UUID
          examples:
            IcI70nGPnGQst4VjAAAJ:
              value: IcI70nGPnGQst4VjAAAJ
            IcI70nGPnGQss4VjAAXJ:
              value: IcI70nGPnGQss4VjAAXJ
            XcI70nGPnGQst4VjAAAA:
              value: XcI70nGPnGQst4VjAAAA
        someId2:
          type: number
          description:  game id
          format: int32
          examples: *a43
        someId3:
          type: number
          description:  link id
          format: int32
          examples:
            "15":
              value: 15
            "21":
              value: 21
            "24":
              value: 24
        someId1:
          type: number
          description:   id
          format: int32
          examples: *a44
        someId4:
          type: number
          description:  someId4
          format: int32
          examples: *a45
        someId5:
          type: string
          description: Unique string identifying the user
          examples: &a47
            "26381576188016421522712081241013542337":
              value: "26381576188016421522712081241013542337"
            "26381576188012421522712081241013541337":
              value: "26381576188012421522712081241013541337"
            "26381577188096421522712081241013542327":
              value: "26381577188096421522712081241013542327"
        propertyX:
          type: string
          description: some property
          examples: *a46
        propertyL:
          type: string
          description: some property
          examples:
            a:
              value: a
            b:
              value: b
            c:
              value: c
            d:
              value: d
        propertyC:
          type: string
          description: some property
          examples:
            A:
              value: A
            B:
              value: B
            C:
              value: C
            D:
              value: D
            E:
              value: E
        propertyT:
          type: number
          description: some proeprty
          format: int32
          examples:
            "23567":
              value: 23567
            "42311":
              value: 42311
            "99111":
              value: 99111
            "732102":
              value: 732102
        connectionTime:
          format: date-time
          type: string
          description: ISO date 
          examples:
            2023-01-17T22:33:30.074Z:
              value: 2023-01-17T22:33:30.074Z
            2021-01-17T22:33:30.074Z:
              value: 2021-01-17T22:33:30.074Z
            2022-01-17T20:33:30.074Z:
              value: 2022-01-17T20:33:30.074Z
        terminated:
          type: boolean
          description: definition
          examples:
            "true":
              value: true
            "false":
              value: false
      required:
        - socketId
        - someId2
        - someId3
        - someId1
        - someId4
        - someId5
        - propertyX
        - propertyL
        - propertyC
        - propertyT
        - connectionTime
        - terminated

If that makes any difference, I'm using Prism Mock server as a target API, but I think that wouldn't really matter as wiretap is in front of it?

@daveshanley
Copy link
Member

This should be resolved, I tried this spec with the latest build and no panics or errors were felt.

@LegendWojciechPolowniak
Copy link

LegendWojciechPolowniak commented Aug 1, 2023

Not sure what this might be about then, I'm running on MacOS (M1 Max) within docker (Linux 3437e2a00357 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 GNU/Linux) so maybe there's something wrong deeper down?

Using the very same OAS spec I shared above, when runing:
prism mock -d api.yaml -p 7777 -h 0.0.0.0
wiretap -s api.yaml -u http://localhost:7777 -p 7700 -m 7701 -w 7702

And making some get requests to http://localhost:7700/v1.0/sessions (via the browser)

I still end up with:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x5862c0]

goroutine 59 [running]:
github.com/pb33f/libopenapi-validator/responses.ValidateResponseSchema(0x400007c000, 0x40001905a0, 0x40000dc000, {0x4000410000, 0xf51, 0x1000}, {0x4000152400, 0x832, 0x4000269598?})
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.10/responses/validate_response.go:134 +0x970
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).checkResponseSchema(0x40002dc400, 0x400026ddd0?, 0x4000124330?, {0x4000124330?, 0x1?}, 0x40002dce00)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.10/responses/validate_body.go:147 +0x224
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).ValidateResponseBody(0x40002dc400, 0x400007c000, 0x40001905a0)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.10/responses/validate_body.go:53 +0x514
github.com/pb33f/wiretap/daemon.(*WiretapService).validateResponse(0x40000a8a80, 0x400011c1e0, {0xe60988?, 0x40002dc400?}, 0x0?)
        /home/runner/work/wiretap/wiretap/daemon/validate.go:24 +0x64
created by github.com/pb33f/wiretap/daemon.(*WiretapService).handleHttpRequest
        /home/runner/work/wiretap/wiretap/daemon/handle_request.go:168 +0xa1c

I'm running wiretap version: 0.0.26 | compiled: Fri, 28 Jul 2023 14:42:38 UTC

@daveshanley
Copy link
Member

OK Thanks, I am re-investigating this issue!

daveshanley added a commit that referenced this issue Aug 1, 2023
No guarantee the type will be set on an invalid schema, so added a fallback check.

Signed-off-by: Dave Shanley <dave@quobix.com>
daveshanley added a commit that referenced this issue Aug 1, 2023
No guarantee the type will be set on an invalid schema, so added a fallback check.

Signed-off-by: Dave Shanley <dave@quobix.com>
@daveshanley
Copy link
Member

Would you be able to try v0.0.27? There was a bug that expected all failed schemas to have a 'type', however prism is not returning a type on the schema, so it was blowing up. This is fixed now

@LegendWojciechPolowniak
Copy link

LegendWojciechPolowniak commented Aug 1, 2023

Hmm I'm still having issues with the same yaml provided earlier, but I think the error trace is different.. (different goroutine) I don't know go so can't really read this. Running this exactly in the same way as mentioned above.
Seems like it might be just prism-proofing? With the same yaml, the error that I'm now getting is:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x586300]

goroutine 165 [running]:
github.com/pb33f/libopenapi-validator/responses.ValidateResponseSchema(0x40000f4100, 0x40005390e0, 0x40005f4c80, {0x40003fe000, 0xf51, 0x1000}, {0x40000e4400, 0x832, 0x40001b60e0?})
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.11/responses/validate_response.go:134 +0x970
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).checkResponseSchema(0x40000b2640, 0x400053a4e0?, 0x40000b6c70?, {0x40000b6c70?, 0x1?}, 0x4000514540)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.11/responses/validate_body.go:147 +0x224
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).ValidateResponseBody(0x40000b2640, 0x40000f4100, 0x40005390e0)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.11/responses/validate_body.go:53 +0x54c
github.com/pb33f/wiretap/daemon.(*WiretapService).validateResponse(0x40000c2c00, 0x4000060060, {0xe609c8?, 0x40000b2640?}, 0x0?)
        /home/runner/work/wiretap/wiretap/daemon/validate.go:24 +0x64
created by github.com/pb33f/wiretap/daemon.(*WiretapService).handleHttpRequest
        /home/runner/work/wiretap/wiretap/daemon/handle_request.go:168 +0xa1c

Other Case (I've removed invalid examples property from Schemas

API.yaml
openapi: 3.0.0
paths:
/v1.0/sessions:
  get:
    operationId: SomeID
    summary: XXX
    description: >-
      XXX
    parameters:
      - name: order
        required: false
        in: query
        schema:
          default: ASC
          enum:
            - ASC
            - DESC
          type: string
      - name: sort
        required: false
        in: query
        schema:
          default: id
          enum:
            - createdAt
            - updatedAt
            - id
            - someId2
            - someId3
            - someId1
            - someId4
            - someId5
            - propertyX
            - propertyL
            - propertyC
            - propertyT
            - connectionTime
            - terminated
          type: string
      - name: pageNumber
        required: false
        in: query
        description: Integer representing a page number to show
        examples:
          "1":
            value: 1
          "2":
            value: 2
          "3":
            value: 3
          "4":
            value: 4
          "5":
            value: 5
        schema:
          minimum: 1
          format: int32
          default: 1
          type: number
      - name: pageSize
        required: false
        in: query
        description: Integer representing a size of a single page
        examples:
          "1":
            value: 1
          "5":
            value: 5
          "10":
            value: 10
          "20":
            value: 20
          "50":
            value: 50
        schema:
          minimum: 1
          maximum: 50
          format: int32
          default: 10
          type: number
      - name: environment
        required: false
        in: query
        description: filter environment params
        style: deepObject
        explode: true
        schema:
          $ref: "#/components/schemas/SessionEnvironmentFilterDto"
      - name: period
        required: false
        in: query
        description: filters sessions by connectionTime
        style: deepObject
        explode: true
        schema:
          $ref: "#/components/schemas/SessionsFromPeriodFilterDto"
    responses:
      "200":
        description: Successfully received session list
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/PageDto"
                - properties:
                    results:
                      type: array
                      items:
                        $ref: "#/components/schemas/SessionDto"
      2XX: &a5
        description: ""
      3XX: &a6
        description: ""
      4XX: &a7
        description: ""
    tags: &a8
      - Sessions
info:
title: XXX
description: >-
  ### XXX
version: 1.3.0
contact:
  name: Wojtek Połowniak
  url: ""
  email: wojciech.polowniak@mail.com
tags: []
servers:
- url: https://server.local
components:
securitySchemes:
  bearer:
    scheme: bearer
    bearerFormat: JWT
    type: http
schemas:
  SessionsFromPeriodFilterDto:
    type: object
    properties:
      from:
        type: string
        description: ISO Date
        format: date-time
      to:
        type: string
        description: ISO Date
        format: date-time
  SessionEnvironmentFilterDto:
    type: object
    properties:
      propertyX:
        type: string
        description: Alpha-2 representation of the country of origin
      someId2:
        type: number
        description:  some id 2
        format: int32
      brandId:
        type: number
        description:  someId4
        format: int32
      someId1:
        type: number
        description:   id
        format: int32
  PageMetaDto:
    type: object
    properties:
      pageNumber:
        type: number
        description: Integer representing a page number to show
        format: int32
        minimum: 1
        default: 1
      pageSize:
        type: number
        description: Integer representing a size of a single page
        format: int32
        minimum: 1
        maximum: 50
        default: 10
      itemCount:
        type: number
        description: Integer representing a total number of items
        format: int32
      pageCount:
        type: number
        description: Integer representing a total number of pages
        format: int32
      hasPreviousPage:
        type: boolean
        description: Boolean representing whether there is a previous page relative to
          the current one
        format: int32
      hasNextPage:
        type: boolean
        description: Boolean representing whether there is a next page relative to the
          current one
        format: int32
    required:
      - pageNumber
      - pageSize
      - itemCount
      - pageCount
      - hasPreviousPage
      - hasNextPage
  PageDto:
    type: object
    properties:
      results:
        type: array
        items:
          type: array
      meta:
        $ref: "#/components/schemas/PageMetaDto"
    required:
      - results
      - meta
  SessionDto:
    type: object
    properties:
      socketId:
        type: string
        description: Socket.io client UUID
      someId2:
        type: number
        description:  game id
        format: int32
      someId3:
        type: number
        description:  link id
        format: int32
      someId1:
        type: number
        description:   id
        format: int32
      someId4:
        type: number
        description:  someId4
        format: int32
      someId5:
        type: string
        description: Unique string identifying the user
      propertyX:
        type: string
        description: some property
      propertyL:
        type: string
        description: some property
      propertyC:
        type: string
        description: some property
      propertyT:
        type: number
        description: some proeprty
        format: int32
      connectionTime:
        format: date-time
        type: string
        description: ISO date 
      terminated:
        type: boolean
        description: definition
    required:
      - socketId
      - someId2
      - someId3
      - someId1
      - someId4
      - someId5
      - propertyX
      - propertyL
      - propertyC
      - propertyT
      - connectionTime
      - terminated
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x88 pc=0x586300]

goroutine 31 [running]:
github.com/pb33f/libopenapi-validator/responses.ValidateResponseSchema(0x4000418300, 0x40004106c0, 0x4000580f00, {0x4000279000, 0xf51, 0x1000}, {0x4000242000, 0x832, 0x400022d6d0?})
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.11/responses/validate_response.go:134 +0x970
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).checkResponseSchema(0x40000b3080, 0x40005357a0?, 0x4000486d90?, {0x4000486d90?, 0x1?}, 0x400052e300)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.11/responses/validate_body.go:147 +0x224
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).ValidateResponseBody(0x40000b3080, 0x4000418300, 0x40004106c0)
        /home/runner/go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.11/responses/validate_body.go:53 +0x54c
github.com/pb33f/wiretap/daemon.(*WiretapService).validateResponse(0x400051c680, 0x4000060c00, {0xe609c8?, 0x40000b3080?}, 0x40000a3d40?)
        /home/runner/work/wiretap/wiretap/daemon/validate.go:24 +0x64
created by github.com/pb33f/wiretap/daemon.(*WiretapService).handleHttpRequest
        /home/runner/work/wiretap/wiretap/daemon/handle_request.go:168 +0xa1c

Basically after hitting wiretap proxy server on http://localhost:7700/v1.0/sessions it crashes on the first response, even with my full OAS spec which has been sanitised and validated in terms of compliance 🤔 The prism server itself is not crashing though

I've been trying a bunch of things and I don't think I'll be able to debug it further myself 😞
I am running the latest build: wiretap version: 0.0.27 | compiled: Tue, 01 Aug 2023 12:49:36 UTC

@daveshanley
Copy link
Member

This is very helpful, thank you for playing whack a mole with me!

@daveshanley
Copy link
Member

My mistake was not publishing the code where the fix was made. The fix was made in https://github.com/pb33f/libopenapi-validator, and the dependencies have been updated in v0.0.28

Thank you for your patience.

@LegendWojciechPolowniak
Copy link

Works perfectly now! Thank you :) I'll definitely keep an eye on the project and report issues if I spot any :) Cheers

@daveshanley
Copy link
Member

Thank you for helping me make better software!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants