flow-cli icon indicating copy to clipboard operation
flow-cli copied to clipboard

CLI crashes when trying to pass array in contract initialization args

Open maggo opened this issue 3 years ago • 3 comments

Problem

CLI crashes on flow deploy when contract init args include { "type": "Array", "value": []}

Steps to Reproduce

Try to deploy a contract locally with following config in the deployment targets:

{
  "name": "Contract",
  "args": [
    {
      "type": "Array",
      "value": [{ "type": "UInt32", "value": "1" }]
    }
  ]
}

Acceptance Criteria

Should not crash ;)

Context

  • Removing the array fixes it
  • Changing types inside doesn't do anything
Error dump
runtime error: invalid memory address or nil pointer dereference
[] []
map[device:map[arch:arm64 num_cpu:10] os:map[name:darwin] runtime:map[go_maxprocs:10 go_numcgocalls:6 go_numroutines:8 name:go version:go1.19.2]]
goroutine 1 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x64
github.com/onflow/flow-cli/internal/command.initCrashReporting.func1(0x1400013d8c0, 0x140004f8d80)
        github.com/onflow/flow-cli/internal/command/command.go:302 +0x1dc
github.com/getsentry/sentry-go.(*Client).processEvent(0x140003a5080, 0x1400013d8c0, 0x140004f8d80, {0x10454e300, 0x140001f2000})
        github.com/getsentry/[email protected]/client.go:548 +0x1a0
github.com/getsentry/sentry-go.(*Client).CaptureEvent(...)
        github.com/getsentry/[email protected]/client.go:365
github.com/getsentry/sentry-go.(*Client).RecoverWithContext(0x14000808000?, {0x0?, 0x0}, {0x1042ee460?, 0x1050fb4e0?}, 0x103a616b8?, {0x10454e300, 0x140001f2000})
        github.com/getsentry/[email protected]/client.go:416 +0x1e8
github.com/getsentry/sentry-go.(*Client).Recover(0x0?, {0x1042ee460?, 0x1050fb4e0?}, 0x0?, {0x10454e300?, 0x140001f2000?})
        github.com/getsentry/[email protected]/client.go:380 +0x80
github.com/getsentry/sentry-go.(*Hub).Recover(0x14000b95298?, {0x1042ee460?, 0x1050fb4e0?})
        github.com/getsentry/[email protected]/hub.go:322 +0xc4
github.com/getsentry/sentry-go.Recover()
        github.com/getsentry/[email protected]/sentry.go:65 +0x44
panic({0x1042ee460, 0x1050fb4e0})
        runtime/panic.go:884 +0x204
github.com/onflow/flow-cli/pkg/flowkit.addAccountContractWithArgs(0x140003b0be0, {{0x14000043170?, 0x69?}, {0x14000ca2000?, 0x10?}}, {0x1400051c610, 0x1, 0x10?})
        github.com/onflow/flow-cli/pkg/[email protected]/transaction.go:118 +0x3b0
github.com/onflow/flow-cli/pkg/flowkit.NewAddAccountContractTransaction(...)
        github.com/onflow/flow-cli/pkg/[email protected]/transaction.go:83
github.com/onflow/flow-cli/pkg/flowkit/services.(*Project).Deploy(0x140003d5170, {0x103b6656a, 0x8}, 0x0)
        github.com/onflow/flow-cli/pkg/[email protected]/services/project.go:294 +0x4b4
github.com/onflow/flow-cli/internal/project.deploy({0x0?, 0x0?, 0x0?}, {0x0?, 0x0?}, {{0x0, 0x0}, {0x103b61930, 0x4}, {0x0, ...}, ...}, ...)
        github.com/onflow/flow-cli/internal/project/deploy.go:64 +0x78
github.com/onflow/flow-cli/internal/command.Command.AddToParent.func1(0x10511c640?, {0x10516d8c0, 0x0, 0x0})
        github.com/onflow/flow-cli/internal/command/command.go:132 +0x3b8
github.com/spf13/cobra.(*Command).execute(0x10511c640, {0x14000134010, 0x0, 0x0})
        github.com/spf13/[email protected]/command.go:876 +0x4b8
github.com/spf13/cobra.(*Command).ExecuteC(0x140007a5900)
        github.com/spf13/[email protected]/command.go:990 +0x354
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:918
main.main()
        github.com/onflow/flow-cli/cmd/flow/main.go:84 +0x4a

maggo avatar Nov 09 '22 19:11 maggo

@sideninja this seems related to Type Encoding problem we hit on events.

https://github.com/onflow/flow-cli/blob/c209f78f72213c9511479d1ed4c590b4a9de5516/pkg/flowkit/transaction.go#L118

bluesign avatar Nov 09 '22 19:11 bluesign

Thank you for the report, I've just noticed the issue in our reports.

@bluesign you are probably right yeah. Will try to look into this asap.

devbugging avatar Nov 10 '22 10:11 devbugging

What is the status on this issue @DylanTinianov?

fotescodev avatar Jan 07 '23 03:01 fotescodev

closing because this is already tracked by https://github.com/onflow/flow-cli/issues/1254

jribbink avatar May 03 '24 16:05 jribbink