From 0f28017108d595f1fda1f3eb1a447b91bd2ecb51 Mon Sep 17 00:00:00 2001 From: david may <1301201+wass3r@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:39:13 +0000 Subject: [PATCH] fix(db/types): add check before owner decrypt (#1166) Co-authored-by: David May <49894298+wass3rw3rk@users.noreply.github.com> --- database/types/repo.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/database/types/repo.go b/database/types/repo.go index e3780f851..584d12923 100644 --- a/database/types/repo.go +++ b/database/types/repo.go @@ -95,9 +95,15 @@ func (r *Repo) Decrypt(key string) error { } // decrypt owner - err = r.Owner.Decrypt(key) - if err != nil { - return err + // Note: In UpdateRepo() (database/repo/update.go), the incoming API repo object + // is cast to a database repo object. The owner object isn't set in this process + // resulting in a zero value for the owner object. A check is performed here + // before decrypting to prevent "unable to decrypt repo..." errors. + if r.Owner.ID.Valid { + err = r.Owner.Decrypt(key) + if err != nil { + return err + } } return nil