lint: fix errcheck for txn.Rollback/Commit and insert in platform

Use lint.LogOnErrRollback for deferred Rollbacks in arcgis.go.
Capture and check errors from txn.Commit and CommunicationLogEntryInsert.
This commit is contained in:
Eli Ribble 2026-05-09 02:17:25 +00:00
parent 4008b9aa25
commit 934fb03ca2
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View file

@ -241,7 +241,7 @@ func updateArcgisUserData(ctx context.Context, user *models.User, oauth *model.O
log.Error().Err(err).Msg("Create transaction")
return
}
defer txn.Rollback(ctx)
defer lint.LogOnErrRollback(txn.Rollback, ctx, "rollback")
account, ag_user, err := updateArcgisAccount(ctx, txn, client, user)
if err != nil {
@ -845,7 +845,7 @@ func insertRowFromFeature(ctx context.Context, table string, sorted_columns []st
if err != nil {
return fmt.Errorf("Unable to start transaction")
}
defer txn.Rollback(ctx)
defer lint.LogOnErrRollback(txn.Rollback, ctx, "rollback")
err = insertRowFromFeatureFS(ctx, txn, table, sorted_columns, feature, org_id)
if err != nil {
@ -857,8 +857,7 @@ func insertRowFromFeature(ctx context.Context, table string, sorted_columns []st
return fmt.Errorf("Failed to insert history: %w", err)
}
txn.Commit(ctx)
if err != nil {
if err := txn.Commit(ctx); err != nil {
return fmt.Errorf("Failed to commit transaction: %w", err)
}
return nil

View file

@ -56,7 +56,12 @@ func communicationMark(ctx context.Context, user User, comm_id int32, status mod
Type: log_type,
User: &user_id,
}
querypublic.CommunicationLogEntryInsert(ctx, txn, log_entry)
txn.Commit(ctx)
_, err = querypublic.CommunicationLogEntryInsert(ctx, txn, log_entry)
if err != nil {
return fmt.Errorf("insert communication log entry: %w", err)
}
if err := txn.Commit(ctx); err != nil {
return fmt.Errorf("commit: %w", err)
}
return nil
}