Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version parsing check skip malformed versions and avoid panic #1469

Merged
merged 4 commits into from
Nov 22, 2024

Conversation

antontroshin
Copy link
Contributor

Description

Fix a panic when an incorrect version is pulled from dapr releases page.
For example, this happened when a new release tag vedge was introduced.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x1961f53]
goroutine 1 [running]:
github.com/hashicorp/go-version.(*Version).String(0x0)
	/home/runner/go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:369 +0x33
github.com/hashicorp/go-version.(*Version).Compare(0x0, 0xc00077c000)
	/home/runner/go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:116 +0x25
github.com/hashicorp/go-version.(*Version).GreaterThan(...)
	/home/runner/go/pkg/mod/github.com/hashicorp/go-version@v1.6.0/version.go:298
github.com/dapr/cli/pkg/version.GetLatestReleaseGithub.func1({0xc00106a000, 0x35bebd, 0x41e000})
	/home/runner/work/cli/cli/pkg/version/version.go:124 +0x1d4
github.com/dapr/cli/pkg/version.GetVersionFromURL({0xc0005fa2a0, 0x2f}, 0x2522[19](https://github.com/dapr/dapr/actions/runs/11962935498/job/33352369506?pr=8301#step:6:20)0)
	/home/runner/work/cli/cli/pkg/version/version.go:102 +0x2b5
github.com/dapr/cli/pkg/version.GetLatestReleaseGithub({0xc0005fa2a0?, 0x2b?})
	/home/runner/work/cli/cli/pkg/version/version.go:107 +0x1f
github.com/dapr/cli/pkg/version.GetDaprVersion()
	/home/runner/work/cli/cli/pkg/version/version.go:63 +0x6a
github.com/dapr/cli/pkg/standalone.Init({0x23e4fe8, 0x6}, {0x23e4fe8, 0x6}, {0x0, 0x0}, 0x1, {0x0, 0x0}, {0x0, ...}, ...)
	/home/runner/work/cli/cli/pkg/standalone/standalone.go:215 +0x21c
github.com/dapr/cli/cmd.glob..func11(0xc000654800?, {0x23e21a3?, 0x4?, 0x23e226b?})
	/home/runner/work/cli/cli/cmd/init.go:174 +0x2f0
github.com/spf13/cobra.(*Command).execute(0x3a89480, {0xc000477d80, 0x1, 0x1})
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xaa3
github.com/spf13/cobra.(*Command).ExecuteC(0x3a86f[20](https://github.com/dapr/dapr/actions/runs/11962935498/job/33352369506?pr=8301#step:6:21))
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/dapr/cli/cmd.Execute({0x275c860?, 0x3997800?}, {0x275c85c?, 0xc0000061a0?})
	/home/runner/work/cli/cli/cmd/dapr.go:78 +0x159
main.main()
	/home/runner/work/cli/cli/main.go:27 +0x2f

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Anton Troshin <anton@diagrid.io>
@antontroshin antontroshin requested review from a team as code owners November 22, 2024 00:18
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
@vamsitp
Copy link

vamsitp commented Nov 22, 2024

@yaron2 Can you review & approve this ASAP plz...

elena-kolevska
elena-kolevska previously approved these changes Nov 22, 2024
@elena-kolevska
Copy link

elena-kolevska commented Nov 22, 2024

Would it make sense to also add the check for alpha versions too, since we're already fixing things in this part of the code?
Also, e2e tests are failing.

@yaron2
Copy link
Member

yaron2 commented Nov 22, 2024

Tests are failing

print warning on error and non-semver version tag

Signed-off-by: Anton Troshin <anton@diagrid.io>
@yaron2 yaron2 merged commit 25d9ece into dapr:master Nov 22, 2024
26 of 27 checks passed
@antontroshin antontroshin deleted the skip-malformed-versions branch November 22, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants