Skip to content

Commit 4c78376

Browse files
waleedlatif1claude
andcommitted
fix(processing): address audit findings across branch
- preprocessing.ts: use undefined (not null) for failed subscription fetch so getUserUsageLimit does a fresh lookup instead of silently falling back to free-tier limits - deployed/route.ts: log warning on loadDeployedWorkflowState failure instead of silently swallowing the error - schedule-execution.ts: remove dead successLog parameter and all call-site arguments left over from logger.debug cleanup - mcp/middleware.ts: drop unused error binding in empty catch - audit/log.ts, wand.ts: promote logger.debug to logger.warn in catch blocks where these are the only failure signal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6004fea commit 4c78376

File tree

6 files changed

+19
-29
lines changed

6 files changed

+19
-29
lines changed

apps/sim/app/api/workflows/[id]/deployed/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
4848
parallels: data.parallels,
4949
variables: data.variables,
5050
}
51-
} catch {
51+
} catch (error) {
52+
logger.warn(`[${requestId}] Failed to load deployed state for workflow ${id}`, { error })
5253
deployedState = null
5354
}
5455

apps/sim/background/schedule-execution.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ async function applyScheduleUpdate(
4040
scheduleId: string,
4141
updates: WorkflowScheduleUpdate,
4242
requestId: string,
43-
context: string,
44-
successLog?: string
43+
context: string
4544
) {
4645
try {
4746
await db.update(workflowSchedule).set(updates).where(eq(workflowSchedule.id, scheduleId))
@@ -349,8 +348,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
349348
status: 'disabled',
350349
},
351350
requestId,
352-
`Failed to disable schedule ${payload.scheduleId} after authentication error`,
353-
`Disabled schedule ${payload.scheduleId} due to authentication failure (401)`
351+
`Failed to disable schedule ${payload.scheduleId} after authentication error`
354352
)
355353
return
356354
}
@@ -368,8 +366,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
368366
status: 'disabled',
369367
},
370368
requestId,
371-
`Failed to disable schedule ${payload.scheduleId} after authorization error`,
372-
`Disabled schedule ${payload.scheduleId} due to authorization failure (403)`
369+
`Failed to disable schedule ${payload.scheduleId} after authorization error`
373370
)
374371
return
375372
}
@@ -384,8 +381,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
384381
status: 'disabled',
385382
},
386383
requestId,
387-
`Failed to disable schedule ${payload.scheduleId} after missing workflow`,
388-
`Disabled schedule ${payload.scheduleId} because the workflow no longer exists`
384+
`Failed to disable schedule ${payload.scheduleId} after missing workflow`
389385
)
390386
return
391387
}
@@ -402,8 +398,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
402398
nextRunAt: nextRetryAt,
403399
},
404400
requestId,
405-
`Error updating schedule ${payload.scheduleId} for rate limit`,
406-
`Updated next retry time for schedule ${payload.scheduleId} due to rate limit`
401+
`Error updating schedule ${payload.scheduleId} for rate limit`
407402
)
408403
return
409404
}
@@ -419,8 +414,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
419414
nextRunAt,
420415
},
421416
requestId,
422-
`Error updating schedule ${payload.scheduleId} after usage limit check`,
423-
`Scheduled next run for ${payload.scheduleId} after usage limit`
417+
`Error updating schedule ${payload.scheduleId} after usage limit check`
424418
)
425419
}
426420
return
@@ -448,8 +442,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
448442
status: shouldDisable ? 'disabled' : 'active',
449443
},
450444
requestId,
451-
`Error updating schedule ${payload.scheduleId} after preprocessing failure`,
452-
`Updated schedule ${payload.scheduleId} after preprocessing failure`
445+
`Error updating schedule ${payload.scheduleId} after preprocessing failure`
453446
)
454447
return
455448
}
@@ -501,8 +494,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
501494
lastQueuedAt: null,
502495
},
503496
requestId,
504-
`Error updating schedule ${payload.scheduleId} after success`,
505-
`Updated next run time for workflow ${payload.workflowId} to ${nextRunAt.toISOString()}`
497+
`Error updating schedule ${payload.scheduleId} after success`
506498
)
507499
return
508500
}
@@ -529,8 +521,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
529521
status: shouldDisable ? 'disabled' : 'active',
530522
},
531523
requestId,
532-
`Error updating schedule ${payload.scheduleId} after failure`,
533-
`Updated schedule ${payload.scheduleId} after failure`
524+
`Error updating schedule ${payload.scheduleId} after failure`
534525
)
535526
} catch (error: unknown) {
536527
const errorMessage = error instanceof Error ? error.message : String(error)
@@ -548,8 +539,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
548539
nextRunAt: nextRetryAt,
549540
},
550541
requestId,
551-
`Error updating schedule ${payload.scheduleId} for service overload`,
552-
`Updated schedule ${payload.scheduleId} retry time due to service overload`
542+
`Error updating schedule ${payload.scheduleId} for service overload`
553543
)
554544
return
555545
}
@@ -576,8 +566,7 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
576566
status: shouldDisable ? 'disabled' : 'active',
577567
},
578568
requestId,
579-
`Error updating schedule ${payload.scheduleId} after execution error`,
580-
`Updated schedule ${payload.scheduleId} after execution error`
569+
`Error updating schedule ${payload.scheduleId} after execution error`
581570
)
582571
}
583572
} catch (error: unknown) {

apps/sim/lib/audit/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ async function insertAuditLog(params: AuditLogParams): Promise<void> {
215215
actorName = row?.name ?? undefined
216216
actorEmail = row?.email ?? undefined
217217
} catch (error) {
218-
logger.debug('Failed to resolve actor info', { error, actorId: params.actorId })
218+
logger.warn('Failed to resolve actor info', { error, actorId: params.actorId })
219219
}
220220
}
221221

apps/sim/lib/execution/preprocessing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export async function preprocessExecution(
265265
}
266266

267267
// ========== STEP 4: Get Subscription ==========
268-
let userSubscription: SubscriptionInfo = null
268+
let userSubscription: SubscriptionInfo | undefined
269269
try {
270270
userSubscription = await getHighestPrioritySubscription(actorUserId)
271271
} catch (error) {
@@ -350,7 +350,7 @@ export async function preprocessExecution(
350350
const rateLimiter = new RateLimiter()
351351
rateLimitInfo = await rateLimiter.checkRateLimitWithSubscription(
352352
actorUserId,
353-
userSubscription,
353+
userSubscription ?? null,
354354
triggerType,
355355
false // not async
356356
)
@@ -419,7 +419,7 @@ export async function preprocessExecution(
419419
success: true,
420420
actorUserId,
421421
workflowRecord,
422-
userSubscription,
422+
userSubscription: userSubscription ?? null,
423423
rateLimitInfo,
424424
executionTimeout: {
425425
sync: getExecutionTimeout(plan, 'sync'),

apps/sim/lib/mcp/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function validateMcpAuth(
7171
workspaceId = body.workspaceId
7272
;(request as any)._parsedBody = body
7373
}
74-
} catch (error) {}
74+
} catch {}
7575
}
7676

7777
if (!workspaceId) {

apps/sim/lib/table/llm/wand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function enrichTableSchema(
5454
const label = table.name ? `${table.name} (${tableId})` : tableId
5555
return `Table schema for ${label}:\n${columnLines}\nBuilt-in columns: createdAt, updatedAt`
5656
} catch (error) {
57-
logger.debug('Failed to fetch table schema', { tableId, error })
57+
logger.warn('Failed to fetch table schema', { tableId, error })
5858
return null
5959
}
6060
}

0 commit comments

Comments
 (0)