From d75414c3bffcd1707b724cc6c1d5a4a269581f5a Mon Sep 17 00:00:00 2001 From: andyosyndoh Date: Sun, 19 Jul 2026 18:03:41 +0300 Subject: [PATCH] fix(warehouse): close load file descriptor in identity uploadFile The load file opened in uploadFile() was never closed on any path, leaking two file descriptors per identity-resolution sync. Also return an error instead of panicking when the file cannot be opened, matching the error handling of the rest of the function. Resolves #7185 --- warehouse/identity/identity.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/warehouse/identity/identity.go b/warehouse/identity/identity.go index 83e523dcd2..2fa3ba5f5b 100644 --- a/warehouse/identity/identity.go +++ b/warehouse/identity/identity.go @@ -454,8 +454,9 @@ func (idr *Identity) writeTableToFile(tableName string, txn *sqlmiddleware.Tx, g func (idr *Identity) uploadFile(ctx context.Context, filePath string, txn *sqlmiddleware.Tx, tableName string, totalRecords int) (err error) { outputFile, err := os.Open(filePath) if err != nil { - panic(err) + return fmt.Errorf("opening load file %s: %w", filePath, err) } + defer func() { _ = outputFile.Close() }() storageProvider := warehouseutils.ObjectStorageType(idr.warehouse.Destination.DestinationDefinition.Name, idr.warehouse.Destination.Config, idr.uploader.UseRudderStorage()) uploader, err := filemanager.New(&filemanager.Settings{ Provider: storageProvider,