Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit212aeff

Browse files
authored
fix(cli): fix potential panic in traceError if unwrapped err is nil (#15166)
Seen while investigating#12721:Root cause was a developer error, but this definitely shouldn't panic.Before:```/ # coder statpanic: runtime error: invalid memory address or nil pointer dereference[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1f12eb0]goroutine 1 [running]:github.com/coder/coder/v2/cli.traceError({0x90e89a0?, 0x40007a8210}) /home/runner/work/coder/coder/cli/root.go:1119 +0x70github.com/coder/coder/v2/cli.cliHumanFormatError({0x40003065a0, 0x1c8}, {0x90e89a0, 0x40007a8210}, 0x40007a81e0?) /home/runner/work/coder/coder/cli/root.go:985 +0x190github.com/coder/coder/v2/cli.cliHumanFormatError({0x40000d0f00, 0x139}, {0x90e89a0, 0x40007a81e0}, 0x40001c4480?) /home/runner/work/coder/coder/cli/root.go:985 +0x1d8github.com/coder/coder/v2/cli.cliHumanFormatError({0x40000d0b40, 0xf}, {0x90e5f00, 0x40006a3a80}, 0x90e5d40?) /home/runner/work/coder/coder/cli/root.go:985 +0x1d8github.com/coder/coder/v2/cli.cliHumanFormatError({0x0, 0x0}, {0x90e5ce0, 0x40003b14c0}, 0x2?) /home/runner/work/coder/coder/cli/root.go:985 +0x1d8github.com/coder/coder/v2/cli.formatRunCommandError(0x40007a8108, 0x400079fce7) /home/runner/work/coder/coder/cli/root.go:1057 +0x30cgithub.com/coder/coder/v2/cli.cliHumanFormatError({0x0, 0x0}, {0x90e5ec0, 0x40007a8108}, 0xaa0aed0?) /home/runner/work/coder/coder/cli/root.go:980 +0xe0github.com/coder/coder/v2/cli.cliHumanFormatError({0x0, 0x0}, {0x90e5160, 0x40007a8120}, 0x90e50e0?) /home/runner/work/coder/coder/cli/root.go:966 +0x144github.com/coder/coder/v2/cli.(*PrettyErrorFormatter).Format(0x400079fda0, {0x90e5160?, 0x40007a8120?}) /home/runner/work/coder/coder/cli/root.go:927 +0x48github.com/coder/coder/v2/cli.(*RootCmd).RunWithSubcommands(0x400068ed80, {0x400053a2c8, 0x30, 0x57}) /home/runner/work/coder/coder/cli/root.go:175 +0x278main.main() /home/runner/work/coder/coder/enterprise/cmd/coder/main.go:11 +0x40```After:```Encountered an error running "coder stat", see "coder stat --help" for more informationerror: <nil>```
1 parent23f61c6 commit212aeff

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎cli/root.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,16 @@ func formatCoderSDKError(from string, err *codersdk.Error, opts *formatOpts) str
11161116
//nolint:errorlint
11171117
functraceError(errerror)string {
11181118
ifuw,ok:=err.(interface{Unwrap()error });ok {
1119-
a,b:=err.Error(),uw.Unwrap().Error()
1119+
vara,bstring
1120+
iferr!=nil {
1121+
a=err.Error()
1122+
}
1123+
ifuw!=nil {
1124+
uwerr:=uw.Unwrap()
1125+
ifuwerr!=nil {
1126+
b=uwerr.Error()
1127+
}
1128+
}
11201129
c:=strings.TrimSuffix(a,b)
11211130
returnc
11221131
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp