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

assert.EqualExportedValues - panic: reflect.MakeSlice of non-slice type [recovered] #1515

Closed
tommynanny opened this issue Dec 5, 2023 · 6 comments

Comments

@tommynanny
Copy link

import (
	"github.com/lib/pq"
)

type User struct {
        ...
	Roles                    pq.StringArray `json:"roles" gorm:"type:text[]"`
}

----
"github.com/lib/pq"
type StringArray []string  //https://github.com/lib/pq/blob/3d613208bca2e74f2a20e04126ed30bcb5c4cc27/array.go#L626
panic: reflect.MakeSlice of non-slice type [recovered]
        panic: reflect.MakeSlice of non-slice type

goroutine 86 [running]:
testing.tRunner.func1.2({0x1027680, 0x1246ea0})
        C:/Program Files/Go/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
        C:/Program Files/Go/src/testing/testing.go:1548 +0x397
panic({0x1027680?, 0x1246ea0?})
        C:/Program Files/Go/src/runtime/panic.go:914 +0x21f
reflect.MakeSlice({0x125aa28, 0x1100c60}, 0x10, 0x10)
        C:/Program Files/Go/src/reflect/value.go:3135 +0x171
github.com/stretchr/testify/assert.copyExportedFields({0x1100c60, 0xc0002c8e00})
        C:/Users/tommy/go/pkg/mod/github.com/stretchr/testify@v1.8.4/assert/assertions.go:113 +0x22f
github.com/stretchr/testify/assert.copyExportedFields({0x111b960, 0xc0002c8e00})
        C:/Users/tommy/go/pkg/mod/github.com/stretchr/testify@v1.8.4/assert/assertions.go:100 +0x5af
github.com/stretchr/testify/assert.ObjectsExportedFieldsAreEqual({0x111b960?, 0xc0002c8e00?}, {0x111b960, 0xc0002c9000})
        C:/Users/tommy/go/pkg/mod/github.com/stretchr/testify@v1.8.4/assert/assertions.go:144 +0x27
bitbucket.org/anra-mission-manager/mmx-registration-service/app/tests/repository_test_test.TestGetUserById.func3(0x0?)
        C:/Users/tommy/Desktop/anra/repo/mmx-registration-service/app/tests/repository_test/user_test.go:108 +0x12c
testing.tRunner(0xc0005841a0, 0xc00033d900)
        C:/Program Files/Go/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 14
        C:/Program Files/Go/src/testing/testing.go:1648 +0x3ad
FAIL    bitbucket.org/anra-mission-manager/mmx-registration-service/app/tests/repository_test   0.873
@hendrywiranto
Copy link
Contributor

Hi!
can you give more explanation about what does this error about? a go.dev example like this would help maintainers understand the issue https://go.dev/play/p/AsRNcxCRdWx

@johnfrankmorgan
Copy link

Hi there, I've been running into this same issue when using arrays.
I've put together an example here: https://go.dev/play/p/XeoP7BQJeQV
I'm using Go 1.21.3

@hendrywiranto
Copy link
Contributor

thank you for the testcase addition @johnfrankmorgan
after some digging, I think it's fixed here #1473
this should be fixed on the next version

also this issue is duplicate of #1404

@johnfrankmorgan
Copy link

That's brilliant, thanks! 😃

@hendrywiranto
Copy link
Contributor

do you have any plan to release some of the fixes? @dolmen

@brackendawson
Copy link
Collaborator

Can confirm this is fixed but not yet released. I intend to tag a release very soon.

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

No branches or pull requests

4 participants