Skip to content

fix: replace reflect.Ptr with reflect.Pointer to fix govet inline#872

Merged
bupd merged 1 commit into
goharbor:mainfrom
Yashbhu:lintissuemain
May 5, 2026
Merged

fix: replace reflect.Ptr with reflect.Pointer to fix govet inline#872
bupd merged 1 commit into
goharbor:mainfrom
Yashbhu:lintissuemain

Conversation

@Yashbhu

@Yashbhu Yashbhu commented May 5, 2026

Copy link
Copy Markdown
Contributor

The updated golangci-lint govet analyzer flags reflect.Ptr as a deprecated alias that should be replaced with the canonical reflect.Pointer constant (introduced in Go 1.18).

Affected files:

  • pkg/utils/error.go
  • pkg/utils/reflect.go

Description

Briefly describe what this pull request does and why the change is needed.

Type of Change

Please select the relevant type.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Changes

  • changed if val.Kind() == reflect.Ptr to if val.Kind() == reflect.Pointer

Copilot AI review requested due to automatic review settings May 5, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates reflection kind checks to use reflect.Pointer instead of the deprecated reflect.Ptr alias, aligning the codebase with newer govet/golangci-lint expectations.

Changes:

  • Replaced reflect.Ptr with reflect.Pointer in config value extraction logic.
  • Replaced reflect.Ptr with reflect.Pointer in Harbor error payload introspection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/utils/reflect.go Updates pointer-kind checks used when extracting configuration values via reflection.
pkg/utils/error.go Updates pointer-kind check used when reflecting into error payloads.
Comments suppressed due to low confidence (1)

pkg/utils/error.go:41

  • ParseHarborErrorMsg can panic here: (1) if err is an interface holding a typed-nil pointer, val.Kind() == reflect.Pointer and val.Elem() will panic unless you guard with !val.IsNil(). (2) FieldByName requires val.Kind() == reflect.Struct; for error implementations that are not structs/pointers-to-structs, calling FieldByName("Payload") will panic. Consider checking val.IsNil() before Elem(), and returning err.Error() early when the dereferenced value is not a struct.
	val := reflect.ValueOf(err)
	if val.Kind() == reflect.Pointer {
		val = val.Elem()
	}
	field := val.FieldByName("Payload")
	if field.IsValid() {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/utils/reflect.go
@Yashbhu

Yashbhu commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@Sypher845 PTAL

@Yashbhu

Yashbhu commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@Vad1mo

@Sypher845

Copy link
Copy Markdown
Contributor

@Yashbhu Thank you for contributing, LGTM. Rebase with main, and let one of the maintainers approve.

…t error

The updated golangci-lint govet analyzer flags reflect.Ptr as a
deprecated alias that should be replaced with the canonical
reflect.Pointer constant (introduced in Go 1.18).

Affected files:
- pkg/utils/error.go
- pkg/utils/reflect.go
- pkg/views/info/list/view.go
- cmd/harbor/root/context/get.go
- cmd/harbor/root/context/delete.go
- cmd/harbor/root/context/update.go

Signed-off-by: yash bahuguna <yashbahuguna918@gmail.com>
@codecov

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.00%. Comparing base (60ad0bd) to head (989a4e1).
⚠️ Report is 147 commits behind head on main.

Files with missing lines Patch % Lines
cmd/harbor/root/context/delete.go 0.00% 2 Missing and 1 partial ⚠️
cmd/harbor/root/context/update.go 0.00% 2 Missing and 1 partial ⚠️
cmd/harbor/root/context/get.go 0.00% 0 Missing and 2 partials ⚠️
pkg/utils/reflect.go 0.00% 2 Missing ⚠️
pkg/views/info/list/view.go 0.00% 2 Missing ⚠️
pkg/utils/error.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #872      +/-   ##
=========================================
- Coverage   10.99%   9.00%   -1.99%     
=========================================
  Files         173     272      +99     
  Lines        8671   13441    +4770     
=========================================
+ Hits          953    1211     +258     
- Misses       7612   12115    +4503     
- Partials      106     115       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@bupd bupd changed the title fix: replace reflect.Ptr with reflect.Pointer to fix govet inline lin… fix: replace reflect.Ptr with reflect.Pointer to fix govet inline May 5, 2026
@bupd bupd merged commit e2b3266 into goharbor:main May 5, 2026
6 of 8 checks passed
micgor32 added a commit to 9elements/converged-security-suite that referenced this pull request May 12, 2026
reflect.Ptr lately started to trigger govet checks [1].
Since it is deprecated anyways [2], replace with reflect.Pointer.

[1] - goharbor/harbor-cli#872
[2] - https://go-review.googlesource.com/c/go/+/359175

Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
micgor32 added a commit to 9elements/converged-security-suite that referenced this pull request May 18, 2026
reflect.Ptr lately started to trigger govet checks [1].
Since it is deprecated anyways [2], replace with reflect.Pointer.

[1] - goharbor/harbor-cli#872
[2] - https://go-review.googlesource.com/c/go/+/359175

Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
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.

govet inline lint failure

4 participants