From 934fb03ca255a22ec7a5866e2af9b343fcfe0862 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Sat, 9 May 2026 02:17:25 +0000 Subject: [PATCH] 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. --- platform/arcgis.go | 7 +++---- platform/communication.go | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/platform/arcgis.go b/platform/arcgis.go index bbaac73f..c8d6e3b2 100644 --- a/platform/arcgis.go +++ b/platform/arcgis.go @@ -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 diff --git a/platform/communication.go b/platform/communication.go index 15e385b5..14f20768 100644 --- a/platform/communication.go +++ b/platform/communication.go @@ -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 }