Skip to content

Commit

Permalink
fix(db/types): add check before owner decrypt (#1166)
Browse files Browse the repository at this point in the history
Co-authored-by: David May <[email protected]>
  • Loading branch information
wass3r and wass3rw3rk authored Aug 26, 2024
1 parent 77ee0a7 commit 0f28017
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions database/types/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f28017

Please sign in to comment.