Begin work on debugging user behavior in early setup

This commit is contained in:
Eli Ribble 2026-01-06 14:46:31 +00:00
parent 655f26e218
commit 97ea4ad3bb
5 changed files with 14 additions and 10 deletions

View file

@ -26,6 +26,7 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
"github.com/Gleipnir-Technology/nidus-sync/debug"
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/alitto/pond/v2"
@ -174,7 +175,7 @@ func updateArcgisUserData(ctx context.Context, user *models.User, access_token s
}
if err != nil {
LogErrorTypeInfo(err)
debug.LogErrorTypeInfo(err)
if errors.Is(err, pgx.ErrNoRows) {
} else {
log.Error().Err(err).Msg("Failed to query for existing org")
@ -310,7 +311,7 @@ func refreshFieldseekerData(ctx context.Context, newOauthCh <-chan struct{}) {
if errors.Is(err, arcgis.InvalidatedRefreshTokenError) {
log.Info().Int("oauth_token.id", int(oauth.ID)).Msg("Marked invalid by the server")
} else {
LogErrorTypeInfo(err)
debug.LogErrorTypeInfo(err)
log.Error().Err(err).Msg("Crashed oauth maintenance goroutine")
}
}

View file

@ -11,6 +11,7 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/db/sql"
"github.com/Gleipnir-Technology/nidus-sync/debug"
"github.com/aarondl/opt/omit"
"github.com/rs/zerolog/log"
"golang.org/x/crypto/bcrypt"
@ -141,16 +142,15 @@ func SignupUser(username string, name string, password string) (*models.User, er
return u, nil
}
// Helper function to translate strings into solid error types for operating on
func findUser(ctx context.Context, user_id int) (*models.User, error) {
user, err := models.FindUser(ctx, db.PGInstance.BobDB, int32(user_id))
if err != nil {
if err.Error() == "No such user" {
if err.Error() == "No such user" || err.Error() == "sql: no rows in result set" {
return nil, &NoUserError{}
} else {
//LogErrorTypeInfo(err)
//log.Error().Err(err).Msg("Unrecognized error. This should be updated in the findUser code")
debug.LogErrorTypeInfo(err)
log.Error().Err(err).Msg("Unrecognized error. This should be updated in the findUser code")
return nil, err
}
}

View file

@ -1,4 +1,4 @@
package main
package debug
import (
"errors"

View file

@ -247,9 +247,11 @@ func getVectorTiles(w http.ResponseWriter, r *http.Request, u *models.User) {
log.Info().Str("org_id", org_id).Str("tileset_id", tileset_id).Str("zoom", zoom).Str("x", x).Str("y", y).Str("format", format).Msg("Get vector tiles")
}
// Respond with an error that is visible to the user
func respondError(w http.ResponseWriter, m string, e error, s int) {
log.Warn().Int("status", s).Err(e).Msg("Responding with an error")
http.Error(w, m, http.StatusBadRequest)
log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error")
http.Error(w, m, s)
}
func postSignin(w http.ResponseWriter, r *http.Request) {

View file

@ -9,6 +9,7 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/db"
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/debug"
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/rs/zerolog/log"
@ -56,7 +57,7 @@ func notifyOauthInvalid(ctx context.Context, user *models.User) {
log.Info().Str("msg", msg).Int("user_id", int(user.ID)).Msg("Refusing to add another notification with the same type")
return
}
LogErrorTypeInfo(err)
debug.LogErrorTypeInfo(err)
log.Error().Err(err).Msg("Failed to insert new notification. This is a programmer bug.")
return
}