danielgtaylor / restish

Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
https://rest.sh/
MIT License
900 stars 74 forks source link

runtime error: invalid memory address with specific OpenAPI specs #222

Open aryeht opened 1 year ago

aryeht commented 1 year ago

Dear RESTiSH,

first of all thank you for providing the tool.

I tried to make API calls to the airbyte API. And I get the runtime error below.

API specs: https://raw.githubusercontent.com/airbytehq/airbyte-platform/main/airbyte-api/src/main/openapi/api.yaml

Full details below. Any info would be grealty appreciated.

Restish version and API configuration

$ restish --version
restish version dev-2023-10-04-15:31

# RESTiSH API configuration:
$ cat ~/.config/restish/apis.json 
{
  "$schema": "https://rest.sh/schemas/apis.json",
  "airbyte": {
    "base": "http://localhost:8006",
    "spec_files": ["https://github.com/airbytehq/airbyte-platform/raw/main/airbyte-api/src/main/openapi/api.yaml"],
    "profiles": {
      "default": {
        "auth": {
          "name": "http-basic",
          "params": {
            "password": "password",
            "username": "airbyte"
          }
        }
      }
    },
    "tls": {}
  }
}

try to consume the /health endpoint (operationId: getHealthCheck) fails:

$ restish airbyte getHealthCheck
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0xebd3e3]

goroutine 1 [running]:
github.com/pb33f/libopenapi/datamodel/low.GenerateHashString({0x0, 0x0})
        /home/tikal/go/pkg/mod/github.com/pb33f/libopenapi@v0.9.7/datamodel/low/extraction_functions.go:707 +0x83
github.com/pb33f/libopenapi/datamodel/low/base.(*Schema).Hash(0xc000542400)
        /home/tikal/go/pkg/mod/github.com/pb33f/libopenapi@v0.9.7/datamodel/low/base/schema.go:249 +0x18fb
github.com/danielgtaylor/restish/openapi.renderSchemaInternal(0xc0000d1680, {0x0, 0x0}, 0x1, 0x10304a0?)
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/openapi/schema.go:215 +0x202a
github.com/danielgtaylor/restish/openapi.renderSchema(...)
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/openapi/schema.go:56
github.com/danielgtaylor/restish/openapi.openapiOperation(_, {_, _}, _, _, _)
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/openapi/openapi.go:410 +0x1b56
github.com/danielgtaylor/restish/openapi.loadOpenAPI3({0x1444ed0, 0xc000119910}, 0x40?, 0xc0001b2d80, 0x101bca0?)
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/openapi/openapi.go:618 +0x16a5
github.com/danielgtaylor/restish/openapi.(*loader).Load(_, {{0xc00003ef18, 0x4}, {0x0, 0x0}, 0x0, {0xc00003ef1f, 0xe}, {0xc00003ef2d, 0x1}, ...}, ...)
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/openapi/openapi.go:803 +0x19c
github.com/danielgtaylor/restish/cli.load(_, {{0xc00003ef18, 0x4}, {0x0, 0x0}, 0x0, {0xc00003ef1f, 0xe}, {0xc00003ef2d, 0x1}, ...}, ...)
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/cli/api.go:81 +0xd8
github.com/danielgtaylor/restish/cli.Load({0xc00003ec78, 0x15}, 0xc000140300)
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/cli/api.go:180 +0x1c4b
github.com/danielgtaylor/restish/cli.Run()
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/cli/cli.go:821 +0xea6
main.main()
        /home/tikal/go/pkg/mod/github.com/danielgtaylor/restish@v0.19.0/main.go:40 +0x245

The corresponding curl command returns successfuly:

curl 'http://localhost:8006/health' \
  -H 'Authorization: Basic YWlyYnl0ZTpwYXNzd29yZA==' 

Successful operation
lorenzo-dev1 commented 10 months ago

I have the same error. I tried to download v0.14.0 of restish and it worked with that version.