Skip to content

[BUG] Exception on first time startup #146

@shurwit

Description

@shurwit

Describe the bug
Currently if you run the latest version of this Building Block for the first time you will get the following exception:

notifications/core.queueLogic.lockQueue.func1({0x7fe60af28698?, 0xc000095a40})
	/notifications-app/core/app_queue.go:167 +0x152
notifications/driven/storage.(*Adapter).PerformTransaction.func1({0x13471a8, 0xc000095a40})
	/notifications-app/driven/storage/adapter.go:66 +0x6e
go.mongodb.org/mongo-driver/mongo.(*Client).UseSessionWithOptions(0x1342550?, {0x1342588, 0xc001075e00}, 0xc00003aea0?, 0xc0000ef598)
	/notifications-app/vendor/go.mongodb.org/mongo-driver/mongo/client.go:768 +0x19c
go.mongodb.org/mongo-driver/mongo.(*Client).UseSession(...)
	/notifications-app/vendor/go.mongodb.org/mongo-driver/mongo/client.go:754
notifications/driven/storage.(*Adapter).PerformTransaction(0xc0000a0058?, 0xc001075da0?, 0x0?)
	/notifications-app/driven/storage/adapter.go:59 +0xe5
notifications/core.queueLogic.lockQueue({0xc0000a41c0, {0x134cb08, 0xc0000a0058}, {0x1343900, 0xc0004a81e0}, 0x0, 0xc00106cea0})
	/notifications-app/core/app_queue.go:184 +0x162
notifications/core.queueLogic.processQueue({0xc0000a41c0, {0x134cb08, 0xc0000a0058}, {0x1343900, 0xc0004a81e0}, 0x0, 0xc00106cea0})
	/notifications-app/core/app_queue.go:53 +0x105
notifications/core.queueLogic.start({0xc0000a41c0, {0x134cb08, 0xc0000a0058}, {0x1343900, 0xc0004a81e0}, 0x0, 0xc00106cea0})
	/notifications-app/core/app_queue.go:40 +0xc6
notifications/core.(*Application).Start(0xc000619b00)
	/notifications-app/core/app.go:68 +0xd0
main.main()
	/notifications-app/main.go:146 +0x1305

To Reproduce
Steps to reproduce the behavior:

  1. Run new instance of Notifications BB
  2. See crash on startup

Expected behavior
This is caused by a nil dereference of the message queue since no queue exists. We need to either handle this nil case appropriately or perform the necessary first time setup when the BB starts to ensure that no manual database configuration is necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions