cloudfoundry / cli

The official command line client for Cloud Foundry
https://docs.cloudfoundry.org/cf-cli
Apache License 2.0
1.75k stars 927 forks source link

Download of droplet/package throws stack trace #2429

Open schmidtsv opened 1 year ago

schmidtsv commented 1 year ago

Please fill out the issue checklist below and provide ALL the requested information.

Describe the bug and the command you saw an issue with I tried both to download a droplet and package with cf cli8. It works in cf cli v7 without issue. What happened

        Command
        cf8 curl /v3/droplets/bdb787f6-29c8-4b11-87e9-a6b47412893c/download

        CLI Version
        8.6.1+b5a352a.2023-02-27

        Error
        template: Display Text:34: unrecognized character in action: U+FFFD '�'

        Stack Trace
            goroutine 1 [running]:
    code.cloudfoundry.org/cli/util/panichandler.HandlePanic()
        /home/runner/work/cli/cli/util/panichandler/handler.go:19 +0x57
    panic({0x1050140, 0xc000540060})
        /opt/hostedtoolcache/go/1.19.6/x64/src/runtime/panic.go:884 +0x212
    text/template.Must(...)
        /opt/hostedtoolcache/go/1.19.6/x64/src/text/template/helper.go:26
    code.cloudfoundry.org/cli/util/ui.generateTranslationFunc.func1({0xc0010c0000, 0xabf0d3}, {0xc000024000, 0x1, 0xc0010c0000?})
        /home/runner/work/cli/cli/util/ui/i18n.go:119 +0x2fb
    code.cloudfoundry.org/cli/util/ui.(*UI).TranslateText(...)
        /home/runner/work/cli/cli/util/ui/ui.go:409
    code.cloudfoundry.org/cli/util/ui.(*UI).DisplayText(0xc00015dce0, {0xc0010c0000, 0xabf0d3}, {0x0?, 0x0?, 0x0?})
        /home/runner/work/cli/cli/util/ui/ui.go:248 +0x14c
    code.cloudfoundry.org/cli/command/v7.CurlCommand.Execute({{{0x13fbc90, 0xc00015dce0}, {0x13fcea0, 0xc00032ca80}, {0x13ed890, 0xc0002dc920}, {0x14000d0, 0xc0005fed90}, 0xc000040300, 0xc0005b8f00}, ...}, ...)
        /home/runner/work/cli/cli/command/v7/curl_command.go:58 +0x2af
    code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).executionWrapper(0xc0003f86c0, {0x7f78e5f2d2d8, 0x1b93818}, {0xc0002dc900, 0x0, 0x2})
        /home/runner/work/cli/cli/util/command_parser/command_parser.go:93 +0x297
    github.com/jessevdk/go-flags.(*Parser).ParseArgs(0xc000401420, {0xc00010e160, 0x2, 0x2})
        /home/runner/go/pkg/mod/github.com/jessevdk/go-flags@v1.4.1-0.20181221193153-c0795c8afcf4/parser.go:331 +0x8d4
    code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).parse(0xc0003f86c0, {0xc00010e160?, 0x2, 0x2}, {0x107b740, 0x1b91e20})
        /home/runner/work/cli/cli/util/command_parser/command_parser.go:224 +0xf3
    code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).ParseCommandFromArgs(...)
        /home/runner/work/cli/cli/util/command_parser/command_parser.go:57
    main.main()
        /home/runner/work/cli/cli/main.go:41 +0x2d4

    goroutine 18 [chan receive]:
    k8s.io/klog/v2.(*loggingT).flushDaemon(0x0?)
        /home/runner/go/pkg/mod/k8s.io/klog/v2@v2.9.0/klog.go:1169 +0x6a
    created by k8s.io/klog/v2.init.0
        /home/runner/go/pkg/mod/k8s.io/klog/v2@v2.9.0/klog.go:420 +0xf6

    goroutine 627 [select]:
    net/http.(*persistConn).writeLoop(0xc00028e7e0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:2392 +0xf5
    created by net/http.(*Transport).dialConn
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:1752 +0x1791

    goroutine 630 [syscall]:
    os/signal.signal_recv()
        /opt/hostedtoolcache/go/1.19.6/x64/src/runtime/sigqueue.go:152 +0x2f
    os/signal.loop()
        /opt/hostedtoolcache/go/1.19.6/x64/src/os/signal/signal_unix.go:23 +0x19
    created by os/signal.Notify.func1.1
        /opt/hostedtoolcache/go/1.19.6/x64/src/os/signal/signal.go:151 +0x2a

    goroutine 591 [IO wait]:
    internal/poll.runtime_pollWait(0x7f78e6088de8, 0x72)
        /opt/hostedtoolcache/go/1.19.6/x64/src/runtime/netpoll.go:305 +0x89
    internal/poll.(*pollDesc).wait(0xc00017e180?, 0xc0002b6000?, 0x0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/internal/poll/fd_poll_runtime.go:84 +0x32
    internal/poll.(*pollDesc).waitRead(...)
        /opt/hostedtoolcache/go/1.19.6/x64/src/internal/poll/fd_poll_runtime.go:89
    internal/poll.(*FD).Read(0xc00017e180, {0xc0002b6000, 0xa80, 0xa80})
        /opt/hostedtoolcache/go/1.19.6/x64/src/internal/poll/fd_unix.go:167 +0x25a
    net.(*netFD).Read(0xc00017e180, {0xc0002b6000?, 0xc00031d750?, 0xc0000baa40?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/fd_posix.go:55 +0x29
    net.(*conn).Read(0xc000013960, {0xc0002b6000?, 0x121168f?, 0xc0000baa30?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/net.go:183 +0x45
    crypto/tls.(*atLeastReader).Read(0xc0005440a8, {0xc0002b6000?, 0x0?, 0x12122d3?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:787 +0x3d
    bytes.(*Buffer).ReadFrom(0xc00032daf8, {0x13dc020, 0xc0005440a8})
        /opt/hostedtoolcache/go/1.19.6/x64/src/bytes/buffer.go:202 +0x98
    crypto/tls.(*Conn).readFromUntil(0xc00032d880, {0x13de260?, 0xc000013960}, 0xa?)
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:809 +0xe5
    crypto/tls.(*Conn).readRecordOrCCS(0xc00032d880, 0x0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:616 +0x116
    crypto/tls.(*Conn).readRecord(...)
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:582
    crypto/tls.(*Conn).Read(0xc00032d880, {0xc0000a6000, 0x1000, 0x1?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:1315 +0x16f
    net/http.(*persistConn).Read(0xc00014a7e0, {0xc0000a6000?, 0xc000422180?, 0xc0000bad30?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:1929 +0x4e
    bufio.(*Reader).fill(0xc000033380)
        /opt/hostedtoolcache/go/1.19.6/x64/src/bufio/bufio.go:106 +0xff
    bufio.(*Reader).Peek(0xc000033380, 0x1)
        /opt/hostedtoolcache/go/1.19.6/x64/src/bufio/bufio.go:144 +0x5d
    net/http.(*persistConn).readLoop(0xc00014a7e0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:2093 +0x1ac
    created by net/http.(*Transport).dialConn
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:1751 +0x173e

    goroutine 626 [IO wait]:
    internal/poll.runtime_pollWait(0x7f78e6088cf8, 0x72)
        /opt/hostedtoolcache/go/1.19.6/x64/src/runtime/netpoll.go:305 +0x89
    internal/poll.(*pollDesc).wait(0xc00017e280?, 0xc000386000?, 0x0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/internal/poll/fd_poll_runtime.go:84 +0x32
    internal/poll.(*pollDesc).waitRead(...)
        /opt/hostedtoolcache/go/1.19.6/x64/src/internal/poll/fd_poll_runtime.go:89
    internal/poll.(*FD).Read(0xc00017e280, {0xc000386000, 0xa000, 0xa000})
        /opt/hostedtoolcache/go/1.19.6/x64/src/internal/poll/fd_unix.go:167 +0x25a
    net.(*netFD).Read(0xc00017e280, {0xc000386000?, 0xc0002dd760?, 0xc00037600d?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/fd_posix.go:55 +0x29
    net.(*conn).Read(0xc000013970, {0xc000386000?, 0xc0000bb910?, 0x5d0528?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/net.go:183 +0x45
    crypto/tls.(*atLeastReader).Read(0xc000118408, {0xc000386000?, 0x0?, 0x1226dd6?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:787 +0x3d
    bytes.(*Buffer).ReadFrom(0xc000150278, {0x13dc020, 0xc000118408})
        /opt/hostedtoolcache/go/1.19.6/x64/src/bytes/buffer.go:202 +0x98
    crypto/tls.(*Conn).readFromUntil(0xc000150000, {0x13de260?, 0xc000013970}, 0x190a?)
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:809 +0xe5
    crypto/tls.(*Conn).readRecordOrCCS(0xc000150000, 0x0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:616 +0x116
    crypto/tls.(*Conn).readRecord(...)
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:582
    crypto/tls.(*Conn).Read(0xc000150000, {0xc0000ca000, 0x1000, 0x1?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/crypto/tls/conn.go:1315 +0x16f
    net/http.(*persistConn).Read(0xc00028e7e0, {0xc0000ca000?, 0xc000422660?, 0xc0000bbd30?})
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:1929 +0x4e
    bufio.(*Reader).fill(0xc0000c62a0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/bufio/bufio.go:106 +0xff
    bufio.(*Reader).Peek(0xc0000c62a0, 0x1)
        /opt/hostedtoolcache/go/1.19.6/x64/src/bufio/bufio.go:144 +0x5d
    net/http.(*persistConn).readLoop(0xc00028e7e0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:2093 +0x1ac
    created by net/http.(*Transport).dialConn
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:1751 +0x173e

    goroutine 592 [select]:
    net/http.(*persistConn).writeLoop(0xc00014a7e0)
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:2392 +0xf5
    created by net/http.(*Transport).dialConn
        /opt/hostedtoolcache/go/1.19.6/x64/src/net/http/transport.go:1752 +0x1791

    goroutine 631 [chan receive]:
    code.cloudfoundry.org/cli/util/configv3.catchSignal(0xc0000177d0?, {0xc00013d680, 0x3d})
        /home/runner/work/cli/cli/util/configv3/write_config.go:64 +0x25
    created by code.cloudfoundry.org/cli/util/configv3.(*Config).WriteConfig
        /home/runner/work/cli/cli/util/configv3/write_config.go:41 +0x28b

Expected behavior I get a stream of the app binaries. On Cli 7.6 it works.

Exact Steps To Reproduce Run the cf curl command for download of either droplet or package in cf8

Provide more context

pmarkham commented 1 year ago

I am hitting the same problem, with a slightly different error.

        Something unexpected happened. This is a bug in cf.

        Please re-run the command that caused this exception with the environment
        variable CF_TRACE set to true.

        Also, please update to the latest cli and try the command again:
        https://code.cloudfoundry.org/cli/releases

        Please create an issue at: https://code.cloudfoundry.org/cli/issues

        Include the below information when creating the issue:

        Command
        cf curl /v3/droplets/d761e4be-e2ae-4ae3-8b6c-1a1317bafc8f/download

        CLI Version
        8.7.1+9c81242.2023-06-15

        Error
        template: Display Text:467: unexpected "{" in command

        Stack Trace
            goroutine 1 [running]:
    code.cloudfoundry.org/cli/util/panichandler.HandlePanic()
        /Users/runner/work/cli/cli/util/panichandler/handler.go:19 +0x57
    panic({0x1c7b980, 0xc0004aa090})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/runtime/panic.go:884 +0x213
    text/template.Must(...)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/text/template/helper.go:26
    code.cloudfoundry.org/cli/util/ui.generateTranslationFunc.func1({0xc00be6c000, 0x586c1ce}, {0xc0004aa000, 0x1, 0x386bd9be5547b7a4?})
        /Users/runner/work/cli/cli/util/ui/i18n.go:119 +0x2fb
    code.cloudfoundry.org/cli/util/ui.(*UI).TranslateText(...)
        /Users/runner/work/cli/cli/util/ui/ui.go:409
    code.cloudfoundry.org/cli/util/ui.(*UI).DisplayText(0xc0002da4d0, {0xc00be6c000, 0x586c1ce}, {0x0?, 0x9c1c0?, 0x206f778f0?})
        /Users/runner/work/cli/cli/util/ui/ui.go:248 +0x14c
    code.cloudfoundry.org/cli/command/v7.CurlCommand.Execute({{{0x2011690, 0xc0002da4d0}, {0x20129d0, 0xc00036aa80}, {0x20027d0, 0xc000431dc0}, {0x2015c10, 0xc000204070}, 0xc000004300, 0xc0000d8360}, ...}, ...)
        /Users/runner/work/cli/cli/command/v7/curl_command.go:58 +0x2bd
    code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).executionWrapper(0xc0003d2160, {0x4f015d8, 0x27d1bc8}, {0xc000431da0, 0x0, 0x2})
        /Users/runner/work/cli/cli/util/command_parser/command_parser.go:93 +0x297
    github.com/jessevdk/go-flags.(*Parser).ParseArgs(0xc0003af5e0, {0xc000118190, 0x2, 0x2})
        /Users/runner/go/pkg/mod/github.com/jessevdk/go-flags@v1.4.1-0.20181221193153-c0795c8afcf4/parser.go:331 +0x8d4
    code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).parse(0xc0003d2160, {0xc000118190?, 0x2, 0x2}, {0x1ca7800, 0x27d01c0})
        /Users/runner/work/cli/cli/util/command_parser/command_parser.go:224 +0xf3
    code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).ParseCommandFromArgs(...)
        /Users/runner/work/cli/cli/util/command_parser/command_parser.go:57
    main.main()
        /Users/runner/work/cli/cli/main.go:41 +0x2d4

    goroutine 18 [chan receive]:
    k8s.io/klog/v2.(*loggingT).flushDaemon(0x0?)
        /Users/runner/go/pkg/mod/k8s.io/klog/v2@v2.9.0/klog.go:1169 +0x6a
    created by k8s.io/klog/v2.init.0
        /Users/runner/go/pkg/mod/k8s.io/klog/v2@v2.9.0/klog.go:420 +0xf6

    goroutine 41 [chan receive]:
    code.cloudfoundry.org/cli/util/configv3.catchSignal(0x102?, {0xc000720000, 0x27})
        /Users/runner/work/cli/cli/util/configv3/write_config.go:64 +0x25
    created by code.cloudfoundry.org/cli/util/configv3.(*Config).WriteConfig
        /Users/runner/work/cli/cli/util/configv3/write_config.go:41 +0x28b

    goroutine 39 [IO wait]:
    internal/poll.runtime_pollWait(0x4cbde18, 0x72)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/runtime/netpoll.go:306 +0x89
    internal/poll.(*pollDesc).wait(0xc0005c0000?, 0xc00036e000?, 0x0)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/internal/poll/fd_poll_runtime.go:84 +0x32
    internal/poll.(*pollDesc).waitRead(...)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/internal/poll/fd_poll_runtime.go:89
    internal/poll.(*FD).Read(0xc0005c0000, {0xc00036e000, 0xa000, 0xa000})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/internal/poll/fd_unix.go:167 +0x299
    net.(*netFD).Read(0xc0005c0000, {0xc00036e000?, 0xc00054e00d?, 0x27e?})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/net/fd_posix.go:55 +0x29
    net.(*conn).Read(0xc00053a008, {0xc00036e000?, 0x1973?, 0xc00054e005?})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/net/net.go:183 +0x45
    crypto/tls.(*atLeastReader).Read(0xc000120f00, {0xc00036e000?, 0xc000120f00?, 0x0?})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/crypto/tls/conn.go:788 +0x3d
    bytes.(*Buffer).ReadFrom(0xc0002ed090, {0x1ff10c0, 0xc000120f00})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/bytes/buffer.go:202 +0x98
    crypto/tls.(*Conn).readFromUntil(0xc0002ece00, {0x4f1e218?, 0xc00053a008}, 0x0?)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/crypto/tls/conn.go:810 +0xe5
    crypto/tls.(*Conn).readRecordOrCCS(0xc0002ece00, 0x0)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/crypto/tls/conn.go:617 +0x116
    crypto/tls.(*Conn).readRecord(...)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/crypto/tls/conn.go:583
    crypto/tls.(*Conn).Read(0xc0002ece00, {0xc00056a000, 0x1000, 0x41?})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/crypto/tls/conn.go:1316 +0x16f
    net/http.(*persistConn).Read(0xc00027a000, {0xc00056a000?, 0xc000592300?, 0xc000518d30?})
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/net/http/transport.go:1943 +0x4e
    bufio.(*Reader).fill(0xc000521260)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/bufio/bufio.go:106 +0xff
    bufio.(*Reader).Peek(0xc000521260, 0x1)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/bufio/bufio.go:144 +0x5d
    net/http.(*persistConn).readLoop(0xc00027a000)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/net/http/transport.go:2107 +0x1ac
    created by net/http.(*Transport).dialConn
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/net/http/transport.go:1765 +0x16ea

    goroutine 40 [select]:
    net/http.(*persistConn).writeLoop(0xc00027a000)
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/net/http/transport.go:2410 +0xf2
    created by net/http.(*Transport).dialConn
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/net/http/transport.go:1766 +0x173d

    goroutine 51 [syscall]:
    os/signal.signal_recv()
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/runtime/sigqueue.go:149 +0x28
    os/signal.loop()
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/os/signal/signal_unix.go:23 +0x19
    created by os/signal.Notify.func1.1
        /Users/runner/hostedtoolcache/go/1.20.5/x64/src/os/signal/signal.go:151 +0x2a

        Your Platform Details
        e.g. Mac OS X 10.11, Windows 8.1 64-bit, Ubuntu 14.04.3 64-bit

        Shell
        e.g. Terminal, iTerm, Powershell, Cygwin, gnome-terminal, terminator

Setting CF_TRACE=1 and rerunning results in an output file that has the trace at the beginning and the downloaded droplet after that. The output from the trace (sanitized) is:

REQUEST: [2023-06-20T08:58:24+10:00]
GET /v3/droplets/d761e4be-e2ae-4ae3-8b6c-1a1317bafc8f/download HTTP/1.1
Host: api.system.example.com
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/json
User-Agent: cf/8.4.0+b4c083e.2022-06-02 (go1.17.10; arm64 darwin)

RESPONSE: [2023-06-20T08:58:42+10:00]
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 92717518
Content-Type: application/zip
Date: Mon, 19 Jun 2023 22:58:26 GMT
Etag: "41011bd8b5c52b2cd7c4c2XXXXXXXXX"
Last-Modified: Mon, 19 Jun 2023 05:30:32 GMT
Server: AmazonS3
X-Amz-Id-2: xxxxxxxxxxzxio0TZwpTKIuYz4SGi3vq4b36WqVJYuIMgobO8AX2971v/1Ktx+ydPNxxxxxxxxxx
X-Amz-Replication-Status: COMPLETED
X-Amz-Request-Id: VN86J5AEN9XXXXXX
X-Amz-Server-Side-Encryption: aws:kms
X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id: arn:aws:kms:ap-southeast-2:012345678901:key/xxxxxxxx-6b13-4c3d-b625-xxxxxxxxxxxx
X-Amz-Version-Id: dEBb4o4ikUcIBdMrGfKPVlXXXXXXXXXX

This happens on both Ubuntu 22.04 using Bash and MacOS 13.4 using zsh

jameshochadel commented 7 months ago

I'm seeing the same issue, with the same command:

CLI Version
8.7.7+583a09a.2023-12-26

Error
template: Display Text:211: unrecognized character in action: U+001F

As a workaround, use the --output arg to download the curl response to a file. I think the problem is that the package archive gets passed to a text display template which attempts to internationalize it, but it fails since the archive is not text (and thus not internationalizable).

a-b commented 15 hours ago

I was able to reproduce this situation. The --output option works well as a workaround. Since cf curl is mainly used for text output, would updating the documentation be sufficient?

a-b commented 14 hours ago

Added to our team backlog.