fix(backend): correctly handle sentry config errors

This commit is contained in:
Łukasz Mierzwa
2020-10-30 17:40:49 +00:00
committed by Łukasz Mierzwa
parent c5d6499bdd
commit 20138a696e
2 changed files with 21 additions and 1 deletions

View File

@@ -373,7 +373,8 @@ func mainSetup(errorHandling pflag.ErrorHandling) (*chi.Mux, error) {
Dsn: config.Config.Sentry.Public,
Release: version,
}); err != nil {
log.Error().Err(err).Msg("Sentry initialization failed")
log.Error().Err(err).Str("dsn", config.Config.Sentry.Public).Msg("Sentry initialization failed")
return nil, fmt.Errorf("sentry configuration is invalid")
}
}

View File

@@ -0,0 +1,19 @@
# Invalid sentry DSN raises an error
karma.bin-should-fail --config.file=karma.yaml --check-config
! stdout .
cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:9093
level=error msg="Sentry initialization failed" error="[Sentry] DsnParseError: invalid scheme" dsn=abcd
level=error msg="Execution failed" error="sentry configuration is invalid"
-- karma.yaml --
alertmanager:
servers:
- name: default
uri: http://127.0.0.1:9093
sentry:
public: abcd