tyk
tyk copied to clipboard
Fix pointer error
Description
logrus_sentry.NewSentryHook
returns a pointer to a SentryHook
. Simply passing a malformed DSN will result in SentryHook
being nil
which we then call hook.Timeout
resulting in a pointer dereference error
Related Issue
No issue created
How This Has Been Tested
I am not sure how this can be tested unfortunately. Happy to be pointed in the right direction.
Screenshots (if appropriate)
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality)
Checklist
- [x] Make sure you are requesting to pull a topic/feature/bugfix branch (right side). If pulling from your own
fork, don't request your
master
! - [x] Make sure you are making a pull request against the
master
branch (left side). Also, you should start your branch off our latestmaster
. - [ ] My change requires a change to the documentation.
- [ ] If you've changed APIs, describe what needs to be updated in the documentation.
- [ ] If new config option added, ensure that it can be set via ENV variable
- [ ] I have updated the documentation accordingly.
- [ ] Modules and vendor dependencies have been updated; run
go mod tidy && go mod vendor
- [ ] When updating library version must provide reason/explanation for this update.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] Check your code additions will not fail linting checks:
- [ ]
go fmt -s
- [ ]
go vet
- [ ]
also I am thinking the debug log about the sentry hook being active should not appear if there is an issue. so something like
hook, err := logrus_sentry.NewSentryHook(gwConfig.SentryCode, logLevel)
if err != nil {
mainLog.Debug(fmt.Sprintf("Sentry hook not error=%s", err.Error())
}
if err == nil {
hook.Timeout = 0
log.Hooks.Add(hook)
rawLog.Hooks.Add(hook)
mainLog.Debug("Sentry hook active")
}
@PericlesTheo thanks for the contribution, we brought this change to our and internal process and we'll be releasing this change in the following patches.
/release to release-4
Working on it! Note that it can take a few minutes.
@titpetric Succesfully merged PR
API tests result: success :white_check_mark: Branch used: refs/heads/master Commit: 1beafa0699c292eda397f3f23eb5fd44071b9030 TT-7124 Fix pointer error (#4291)
logrus_sentry.NewSentryHook
returns a pointer to a SentryHook
.
Simply passing a malformed DSN will result in SentryHook
being nil
which we then call hook.Timeout
resulting in a pointer dereference
error
Triggered by: push (@titpetric)
Execution page
/release to release-4-lts
Working on it! Note that it can take a few minutes.
@titpetric Succesfully merged PR