danielgtaylor / restish

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

Including '%' generates `invalid memory address or nil pointer dereference` #245

Open brendan-stephens opened 3 months ago

brendan-stephens commented 3 months ago
restish --version
restish version 0.20.0

The api function here takes a SQL search pattern, where % is a wildcard. This causes a null pointer error.

restish api search '%@domain.com' -v
DEBUG: API loading took 10.817125ms
DEBUG: Configuration: map[api-name:api app-name:restish 
...
rsh-filter: rsh-header:[] rsh-ignore-status-code:false rsh-insecure:false rsh-no-cache:false rsh-no-paginate:false rsh-output-format:auto rsh-profile:default rsh-query:[] rsh-raw:false rsh-retry:2 rsh-server: rsh-timeout:0s rsh-verbose:true server-index:0 tty:true]

ERROR: Caught error: runtime error: invalid memory address or nil pointer dereference
DEBUG: goroutine 1 [running]:
runtime/debug.Stack()
    /opt/hostedtoolcache/go/1.18.10/x64/src/runtime/debug/stack.go:24 +0x68
github.com/danielgtaylor/restish/cli.Run.func1()
    /home/runner/work/restish/restish/cli/cli.go:849 +0x68
panic({0x105ce3fc0, 0x106472320})
    /opt/hostedtoolcache/go/1.18.10/x64/src/runtime/panic.go:838 +0x204
github.com/danielgtaylor/restish/cli.Operation.command.func1(0x140000c9b00?, {0x14000392da0, 0x1, 0x2})
    /home/runner/work/restish/restish/cli/operation.go:141 +0x7e4
github.com/spf13/cobra.(*Command).execute(0x140000c9b00, {0x14000392d80, 0x2, 0x2})
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x5dc
github.com/spf13/cobra.(*Command).ExecuteC(0x1400034a600)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
    /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/danielgtaylor/restish/cli.Run()
    /home/runner/work/restish/restish/cli/cli.go:857 +0x9a8
main.main()
    /home/runner/work/restish/restish/main.go:40 +0x370

Configuration:

{
  "\$schema": "https://rest.sh/schemas/apis.json",
  "admin-api": {
    "base": "https://api.com/v1",
    "profiles": {
      "default": {
        "headers": {
          "Authorization": $ACCESS_TOKEN"
        }
      }
    },
    "tls": {}
  }
}