Skip to content

Commit 3d32a01

Browse files
dominikvagnerMichaelMraka
authored andcommitted
fix: add guard for owner_id nil dereference
1 parent 986f68e commit 3d32a01

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

listener/upload.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ func hostTemplate(tx *gorm.DB, accountID int, host *Host) *int64 {
281281
var templateID *int64
282282

283283
if hasTemplateRepo(&host.SystemProfile) {
284+
if host.SystemProfile.OwnerID == nil {
285+
utils.LogWarn("inventoryID", host.ID, "Unable to assign templates: missing owner_id")
286+
return templateID
287+
}
288+
284289
// check system's env in candlepin
285290
resp, err := callCandlepinEnvironment(base.Context, host.SystemProfile.OwnerID.String())
286291
if err != nil {

0 commit comments

Comments
 (0)