You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(tables): enforce plan limits in mothership user_table tool (#4832)
* fix(tables): enforce plan limits in mothership user_table tool
* improvement(tables): truncate over-limit CSV imports to the plan cap instead of rejecting
* fix(tables): log rollback failures and surface a clear reason on failed CSV import
logger.error('Failed to roll back table after import failure',{
794
+
tableId: table.id,
795
+
error: toError(cleanupError).message,
796
+
})
797
+
})
798
+
constreason=toError(insertError).message
799
+
constcause=
800
+
insertErrorinstanceofError&&insertError.cause
801
+
? toError(insertError.cause).message
802
+
: undefined
803
+
logger.error('Failed to import rows into new table',{
804
+
tableId: table.id,
805
+
fileName: file.name,
806
+
error: reason,
807
+
cause,
808
+
})
809
+
return{
810
+
success: false,
811
+
message: `Failed to import rows from "${file.name}" — the table was rolled back. ${cause ? `${reason} (${cause})` : reason}`,
812
+
}
813
+
}
777
814
778
815
logger.info('Table created from file',{
779
816
tableId: table.id,
780
817
fileName: file.name,
781
818
columns: columns.length,
782
819
rows: inserted,
820
+
droppedRows,
783
821
userId: context.userId,
784
822
})
785
823
824
+
constcreatedMessage=`Created table "${table.name}" with ${columns.length} columns and ${inserted.toLocaleString()} rows from "${file.name}"`
825
+
constmessage=
826
+
droppedRows>0
827
+
? `${createdMessage}. Dropped ${droppedRows.toLocaleString()} row(s) that exceed this plan's limit of ${planLimits.maxRowsPerTable.toLocaleString()} rows per table.`
828
+
: createdMessage
829
+
786
830
return{
787
831
success: true,
788
-
message: `Created table "${table.name}" with ${columns.length} columns and ${inserted} rows from "${file.name}"`,
0 commit comments