Skip to content

Panic while using bitbucketserver provider for git commit status #700

@gdasson

Description

@gdasson

Describe the bug

The support for Bitbucket Server/Datacenter as a provider for git commit status was introduced by this PR

Unfortunately, while testing the code using self signed certificates, I noticed a bug in the code that's causing a panic: runtime error: invalid memory address or nil pointer dereference error

To Reproduce:

Steps to reproduce the behavior:

  1. Enable bitbucket server provider for git commit status like below:
apiVersion: notification.toolkit.fluxcd.io/v1beta3
kind: Provider
metadata:
  name: server-commit-status-provider
  namespace: flux-system
spec:
  address: https://test.internal.server:8443/scm/foo/bar.git
  secretRef:
    name: token
  type: bitbucketserver
  1. The certificate for the server is self signed, but certSecretRef was not provided

Current Actual behavior:

Notification controller dies with a panic error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1659578]

goroutine 236 [running]:
github.com/fluxcd/notification-controller/internal/notifier.BitbucketServer.duplicateBitbucketServerStatus({{0x40007d3766, 0x5}, {0x40007d376c, 0xd}, {0x40006db680, 0x24}, {0x40007d3740, 0x3d}, {0x400071cb70, 0x21}, ...}, ...)
	github.com/fluxcd/notification-controller/internal/notifier/bitbucketserver.go:195 +0x258
github.com/fluxcd/notification-controller/internal/notifier.BitbucketServer.Post({{0x40007d3766, 0x5}, {0x40007d376c, 0xd}, {0x40006db680, 0x24}, {0x40007d3740, 0x3d}, {0x400071cb70, 0x21}, ...}, ...)
	github.com/fluxcd/notification-controller/internal/notifier/bitbucketserver.go:155 +0x3a8
github.com/fluxcd/notification-controller/internal/server.(*EventServer).dispatchNotification.func1({0x2008500, 0x4000523e60}, {{{0x40007c6870, 0xd}, {0x40007c6880, 0xb}, {0x40007be588, 0x18}, {0x40006daf60, 0x24}, ...}, ...})
	github.com/fluxcd/notification-controller/internal/server/event_handlers.go:210 +0xc0
created by github.com/fluxcd/notification-controller/internal/server.(*EventServer).dispatchNotification in goroutine 234
	github.com/fluxcd/notification-controller/internal/server/event_handlers.go:207 +0x1d0

Expected behavior:

Notification controller should handle the issue gracefully and emit an error message in its logs

Current workaround:

Please make sure to specify certSecretRef (a valid CA cert) to trust the self signed cert

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/alertingAlerting related issues and PRsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions