From 372b4e5dcdc0767be6ee2efa54b562f926e6130e Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 27 Feb 2019 06:05:22 -0500 Subject: [PATCH] Fix nil pointer when navigating to bad invite URL Previously when looking up an invite ID that doesn't exist, the database call wouldn't communicate its non-existence in a standard way -- returning a nil object and nil error. Now the database call returns a 404 error, so handlers can show the correct page. --- database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database.go b/database.go index 1fa2c88..af6ae96 100644 --- a/database.go +++ b/database.go @@ -2234,7 +2234,7 @@ func (db *datastore) GetUserInvite(id string) (*Invite, error) { err := db.QueryRow("SELECT id, max_uses, created, expires, inactive FROM userinvites WHERE id = ?", id).Scan(&i.ID, &i.MaxUses, &i.Created, &i.Expires, &i.Inactive) switch { case err == sql.ErrNoRows: - return nil, nil + return nil, impart.HTTPError{http.StatusNotFound, "Invite doesn't exist."} case err != nil: log.Error("Failed selecting invite: %v", err) return nil, err