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

fix: panic when setting bool via envvar #734

Merged
merged 1 commit into from
Nov 16, 2024
Merged

fix: panic when setting bool via envvar #734

merged 1 commit into from
Nov 16, 2024

Conversation

jmattheis
Copy link
Member

@jmattheis jmattheis commented Nov 15, 2024

Don't know exactly what the problem is, but not having pointers for the booleans seem to help and they seem unnecessary.

$ docker run -e GOTIFY_SERVER_SSL_ENABLED=true --rm gotify/server:2.6.0
Starting Gotify version 2.6.0@2024-11-15-19:19:19
panic: reflect.Set: value of type bool is not assignable to type *bool

goroutine 1 [running]:
reflect.Value.assignTo({0xf5e000?, 0x1c375a8?, 0x19?}, {0x108809b, 0xb}, 0xf42960, 0x0)
        /usr/local/go/src/reflect/value.go:3358 +0x299
reflect.Value.Set({0xf42960?, 0xc0000cd200?, 0x4?}, {0xf5e000?, 0x1c375a8?, 0xf42960?})
        /usr/local/go/src/reflect/value.go:2313 +0xe6
github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xc0002eecc0?, 0xc0000cd200?}, {0xc0002ef0c0, 0x3, 0x4})
        /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:307 +0xc11
github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xc0002eec80?, 0xc0000cd1e0?}, {0xc0002ad880, 0x2, 0x2})
        /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:330 +0xe79
github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xf41420?, 0xc0000cd1e0?}, {0xc0002f0610, 0x1, 0x1})
        /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:330 +0xe79
github.com/jinzhu/configor.(*Configor).load(0xc0002f0270, {0xf41420, 0xc0000cd1e0}, 0x0, {0xc0002ad7a0?, 0x1c7c000?, 0xc0002ad7a0?})
        /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:415 +0x3f8
github.com/jinzhu/configor.(*Configor).Load(0xc0002f0270, {0xf41420, 0xc0000cd1e0}, {0xc0002ad7a0, 0x2, 0x2})
        /go/pkg/mod/github.com/jinzhu/[email protected]/configor.go:92 +0x13c
github.com/gotify/server/v2/config.Get()
        /src/gotify/config/config.go:69 +0xf3
main.main()
        /src/gotify/app.go:34 +0x1e5

See #731 (comment)

Is an upstream issue: jinzhu/configor#92

@jmattheis jmattheis requested a review from a team as a code owner November 15, 2024 21:52
    $ docker run -e GOTIFY_SERVER_SSL_ENABLED=true --rm gotify/server:2.6.0
    Starting Gotify version 2.6.0@2024-11-15-19:19:19
    panic: reflect.Set: value of type bool is not assignable to type *bool

    goroutine 1 [running]:
    reflect.Value.assignTo({0xf5e000?, 0x1c375a8?, 0x19?}, {0x108809b, 0xb}, 0xf42960, 0x0)
            /usr/local/go/src/reflect/value.go:3358 +0x299
    reflect.Value.Set({0xf42960?, 0xc0000cd200?, 0x4?}, {0xf5e000?, 0x1c375a8?, 0xf42960?})
            /usr/local/go/src/reflect/value.go:2313 +0xe6
    github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xc0002eecc0?, 0xc0000cd200?}, {0xc0002ef0c0, 0x3, 0x4})
            /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:307 +0xc11
    github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xc0002eec80?, 0xc0000cd1e0?}, {0xc0002ad880, 0x2, 0x2})
            /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:330 +0xe79
    github.com/jinzhu/configor.(*Configor).processTags(0xc0002f0270, {0xf41420?, 0xc0000cd1e0?}, {0xc0002f0610, 0x1, 0x1})
            /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:330 +0xe79
    github.com/jinzhu/configor.(*Configor).load(0xc0002f0270, {0xf41420, 0xc0000cd1e0}, 0x0, {0xc0002ad7a0?, 0x1c7c000?, 0xc0002ad7a0?})
            /go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:415 +0x3f8
    github.com/jinzhu/configor.(*Configor).Load(0xc0002f0270, {0xf41420, 0xc0000cd1e0}, {0xc0002ad7a0, 0x2, 0x2})
            /go/pkg/mod/github.com/jinzhu/[email protected]/configor.go:92 +0x13c
    github.com/gotify/server/v2/config.Get()
            /src/gotify/config/config.go:69 +0xf3
    main.main()
            /src/gotify/app.go:34 +0x1e5
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 79.42%. Comparing base (8639316) to head (6b3ff77).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
runner/runner.go 0.00% 3 Missing ⚠️
router/router.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #734   +/-   ##
=======================================
  Coverage   79.42%   79.42%           
=======================================
  Files          56       56           
  Lines        2639     2639           
=======================================
  Hits         2096     2096           
  Misses        452      452           
  Partials       91       91           

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

Copy link
Member

@eternal-flame-AD eternal-flame-AD left a comment

Choose a reason for hiding this comment

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

https://github.com/jinzhu/configor/blob/f7a0fc7c9fc697269b1749c1cc472d49baa8d33c/utils.go#L295

Seems like for some reason this is put before dereferencing the pointer. But this shouldn't need to be a pointer anyways so :)

@jmattheis jmattheis merged commit cc7da2a into master Nov 16, 2024
3 of 4 checks passed
@jmattheis jmattheis deleted the panic-bool branch November 16, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants