Skip to content

Commit afb696c

Browse files
committed
Make some configurations resilient to empty settings
1 parent d188997 commit afb696c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

configuration/network.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import (
2626

2727
// UserAgent returns the user agent (mainly used by HTTP clients)
2828
func UserAgent(settings *viper.Viper) string {
29-
subComponent := settings.GetString("network.user_agent_ext")
29+
subComponent := ""
30+
if settings != nil {
31+
subComponent = settings.GetString("network.user_agent_ext")
32+
}
3033
if subComponent != "" {
3134
subComponent = " " + subComponent
3235
}
@@ -41,7 +44,7 @@ func UserAgent(settings *viper.Viper) string {
4144

4245
// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)
4346
func NetworkProxy(settings *viper.Viper) (*url.URL, error) {
44-
if !settings.IsSet("network.proxy") {
47+
if settings == nil || !settings.IsSet("network.proxy") {
4548
return nil, nil
4649
}
4750
if proxyConfig := settings.GetString("network.proxy"); proxyConfig == "" {

0 commit comments

Comments
 (0)