MCPcopy Index your code
hub / github.com/simstudioai/sim / logPreprocessingError

Function logPreprocessingError

apps/sim/lib/execution/preprocessing.ts:762–821  ·  view source on GitHub ↗

* Helper function to log preprocessing errors to the database * * This ensures users can see why their workflow execution was blocked.

(params: {
  workflowId: string
  executionId: string
  triggerType: string
  requestId: string
  userId: string
  workspaceId: string
  errorMessage: string
  loggingSession?: LoggingSession
  triggerData?: SessionStartParams['triggerData']
})

Source from the content-addressed store, hash-verified

760 * This ensures users can see why their workflow execution was blocked.
761 */
762async function logPreprocessingError(params: {
763 workflowId: string
764 executionId: string
765 triggerType: string
766 requestId: string
767 userId: string
768 workspaceId: string
769 errorMessage: string
770 loggingSession?: LoggingSession
771 triggerData?: SessionStartParams['triggerData']
772}): Promise<void> {
773 const {
774 workflowId,
775 executionId,
776 triggerType,
777 requestId,
778 userId,
779 workspaceId,
780 errorMessage,
781 loggingSession,
782 triggerData,
783 } = params
784
785 if (!workspaceId) {
786 logger.warn(`[${requestId}] Cannot log preprocessing error: no workspaceId available`, {
787 workflowId,
788 executionId,
789 errorMessage,
790 })
791 return
792 }
793
794 try {
795 const session =
796 loggingSession || new LoggingSession(workflowId, executionId, triggerType, requestId)
797
798 await session.safeStart({
799 userId,
800 workspaceId,
801 variables: {},
802 triggerData,
803 })
804
805 await session.safeCompleteWithError({
806 error: {
807 message: errorMessage,
808 stackTrace: undefined,
809 },
810 traceSpans: [],
811 skipCost: true, // Preprocessing errors should not charge - no execution occurred
812 })
813 } catch (error) {
814 logger.error(`[${requestId}] Failed to log preprocessing error`, {
815 error,
816 workflowId,
817 executionId,
818 })
819 // Don't throw - error logging should not block the error response

Callers 1

recordPreprocessingErrorFunction · 0.85

Calls 4

safeStartMethod · 0.80
safeCompleteWithErrorMethod · 0.80
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected