Skip to content

Error with "cf env" when a variable value has double curly braces '{{' in it #2325

@mokrane-amzal

Description

@mokrane-amzal

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

  • I reviewed open and closed github issues that may be related to my problem.
  • I tried updating to the latest version of the CF CLI to see if it fixed my problem.
  • I attempted to run the command with CF_TRACE=1 to help debug the issue.
  • I am reporting a bug that others will be able to reproduce.

Describe the bug and the command you saw an issue with
I have an app where an environment variable has a value with double curly braces '{{' in it.
If I run 'cf env MY_APP', some of the env info is displayed then an error is returned.

What happened
The command returned: "Something unexpected happened. This is a bug in cf8."

Expected behavior
The cf env command should succeed, displaying all variables and their values.

Exact Steps To Reproduce
Steps to reproduce the behavior; include the exact CLI commands and verbose output:

  1. Run cf set-env MY_APP 'MY_VAR' '{{'
  2. Run cf env MY_APP
  3. See error
		Something unexpected happened. This is a bug in cf8.

		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
		cf8 env MY_APP

		CLI Version
		8.5.0+73aa161.2022-09-12

		Error
		template: Display Text:1: unclosed action

		Stack Trace
			goroutine 1 [running]:
	code.cloudfoundry.org/cli/util/panichandler.HandlePanic()
		/Users/runner/work/cli/cli/util/panichandler/handler.go:19 +0x4c
	panic({0x1051aa520, 0x1400058cc30})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/runtime/panic.go:838 +0x204
	text/template.Must(...)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/text/template/helper.go:25
	code.cloudfoundry.org/cli/util/ui.generateTranslationFunc.func1({0x1400078c490, 0xa}, {0x1400058cbc0, 0x1, 0x14000112000?})
		/Users/runner/work/cli/cli/util/ui/i18n.go:119 +0x2bc
	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(0x140003ba000, {0x1400078c490, 0xa}, {0x0?, 0x2?, 0xe?})
		/Users/runner/work/cli/cli/util/ui/ui.go:248 +0x15c
	code.cloudfoundry.org/cli/command/v7.EnvCommand.displayEnvGroup({{{0x10537e4c8, 0x140003ba000}, {0x10537f140, 0x1400003ca80}, {0x105376d58, 0x14000192ce0}, {0x105381580, 0x1400044c700}, 0x14000482000, 0x1400040d1a0}, ...}, ...)
		/Users/runner/work/cli/cli/command/v7/env_command.go:96 +0x138
	code.cloudfoundry.org/cli/command/v7.EnvCommand.Execute({{{0x10537e4c8, 0x140003ba000}, {0x10537f140, 0x1400003ca80}, {0x105376d58, 0x14000192ce0}, {0x105381580, 0x1400044c700}, 0x14000482000, 0x1400040d1a0}, ...}, ...)
		/Users/runner/work/cli/cli/command/v7/env_command.go:67 +0x658
	code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).executionWrapper(0x1400018c350, {0x10cededd8, 0x105ad5150}, {0x14000192cc0, 0x0, 0x2})
		/Users/runner/work/cli/cli/util/command_parser/command_parser.go:93 +0x22c
	github.com/jessevdk/go-flags.(*Parser).ParseArgs(0x140003df1f0, {0x14000110190, 0x2, 0x2})
		/Users/runner/go/pkg/mod/github.com/jessevdk/go-flags@v1.4.1-0.20181221193153-c0795c8afcf4/parser.go:331 +0x704
	code.cloudfoundry.org/cli/util/command_parser.(*CommandParser).parse(0x1400018c350, {0x14000110190?, 0x2, 0x2}, {0x1051d56a0, 0x105ad2760})
		/Users/runner/work/cli/cli/util/command_parser/command_parser.go:224 +0xd0
	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 +0x284

	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 +0x60
	created by k8s.io/klog/v2.init.0
		/Users/runner/go/pkg/mod/k8s.io/klog/v2@v2.9.0/klog.go:420 +0x154

	goroutine 670 [chan receive]:
	code.cloudfoundry.org/cli/util/configv3.catchSignal(0x0?, {0x1400013cbd0, 0x28})
		/Users/runner/work/cli/cli/util/configv3/write_config.go:64 +0x2c
	created by code.cloudfoundry.org/cli/util/configv3.(*Config).WriteConfig
		/Users/runner/work/cli/cli/util/configv3/write_config.go:41 +0x214

	goroutine 702 [syscall]:
	os/signal.signal_recv()
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/runtime/sigqueue.go:148 +0x30
	os/signal.loop()
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/os/signal/signal_unix.go:23 +0x20
	created by os/signal.Notify.func1.1
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/os/signal/signal.go:151 +0x30

	goroutine 673 [IO wait]:
	internal/poll.runtime_pollWait(0x10cd36718, 0x72)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/runtime/netpoll.go:302 +0xa4
	internal/poll.(*pollDesc).wait(0x140002c7400?, 0x140004c8000?, 0x0)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/internal/poll/fd_poll_runtime.go:83 +0x2c
	internal/poll.(*pollDesc).waitRead(...)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/internal/poll/fd_poll_runtime.go:88
	internal/poll.(*FD).Read(0x140002c7400, {0x140004c8000, 0x3b02, 0x3b02})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/internal/poll/fd_unix.go:167 +0x1e4
	net.(*netFD).Read(0x140002c7400, {0x140004c8000?, 0x14000326005?, 0x6?})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/net/fd_posix.go:55 +0x2c
	net.(*conn).Read(0x14000122030, {0x140004c8000?, 0x140000267c8?, 0x1044a8028?})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/net/net.go:183 +0x38
	crypto/tls.(*atLeastReader).Read(0x140001840d8, {0x140004c8000?, 0x0?, 0x10449e018?})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/crypto/tls/conn.go:785 +0x44
	bytes.(*Buffer).ReadFrom(0x140003be278, {0x105366378, 0x140001840d8})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/bytes/buffer.go:204 +0x94
	crypto/tls.(*Conn).readFromUntil(0x140003be000, {0x10cdaffc8?, 0x14000122030}, 0xa000000000000f5?)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/crypto/tls/conn.go:807 +0xd8
	crypto/tls.(*Conn).readRecordOrCCS(0x140003be000, 0x0)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/crypto/tls/conn.go:614 +0xdc
	crypto/tls.(*Conn).readRecord(...)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/crypto/tls/conn.go:582
	crypto/tls.(*Conn).Read(0x140003be000, {0x1400070a000, 0x1000, 0x0?})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/crypto/tls/conn.go:1285 +0x180
	net/http.(*persistConn).Read(0x1400014f7a0, {0x1400070a000?, 0x104499060?, 0x14000040060?})
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1929 +0x54
	bufio.(*Reader).fill(0x140005941e0)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/bufio/bufio.go:106 +0x100
	bufio.(*Reader).Peek(0x140005941e0, 0x1)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/bufio/bufio.go:144 +0x64
	net/http.(*persistConn).readLoop(0x1400014f7a0)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:2093 +0x148
	created by net/http.(*Transport).dialConn
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1750 +0x11f4

	goroutine 674 [select]:
	net/http.(*persistConn).writeLoop(0x1400014f7a0)
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:2392 +0xa4
	created by net/http.(*Transport).dialConn
		/Users/runner/hostedtoolcache/go/1.18.5/x64/src/net/http/transport.go:1751 +0x1240


		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

Provide more context

  • platform and shell details ( e.g. Mac OS X 10.11 iTerm)
    Mac OS X 12.6, Apple M1 Max
  • version of the CLI you are running
    8.5.0+73aa161.2022-09-12
  • version of the CC API Release you are on
    3.123.0

Additional note: This issue occurs also with cf 7.5.0+0ad1d63.2022-06-04 but not with cf 6.53.0+8e2b70a4a.2020-10-01.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions