Skip to content

Commit 00feae9

Browse files
committed
fix(webhooks): type blank Plane tokens and non-string Airtable IDs as config errors, dedupe resume refusal logs
1 parent 0b1b3c7 commit 00feae9

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎apps/sim/lib/webhooks/providers/airtable.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { db } from '@sim/db'
22
import { account, webhook } from '@sim/db/schema'
33
import { createLogger } from '@sim/logger'
4+
import { toStringOrNull } from '@sim/utils/coerce'
45
import { toRecord } from '@sim/utils/object'
56
import { eq } from 'drizzle-orm'
67
import { validateAirtableId } from '@/lib/core/security/input-validation'
@@ -436,12 +437,12 @@ export const airtableHandler: WebhookProviderHandler = {
436437
}: SubscriptionContext): Promise<SubscriptionResult | undefined> {
437438
try {
438439
const config = getProviderConfig(webhookRecord)
439-
const { baseId, tableId, includeCellValuesInFieldIds, credentialId } = config as {
440-
baseId?: string
441-
tableId?: string
440+
const { includeCellValuesInFieldIds, credentialId } = config as {
442441
includeCellValuesInFieldIds?: string
443442
credentialId?: string
444443
}
444+
const baseId = toStringOrNull(config.baseId)
445+
const tableId = toStringOrNull(config.tableId)
445446

446447
if (!baseId || !tableId) {
447448
logger.warn(`[${requestId}] Missing baseId or tableId for Airtable webhook creation.`, {

‎apps/sim/lib/webhooks/providers/errors.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export class WebhookDeploymentConfigurationError extends Error {
2-
constructor(message: string) {
2+
constructor(message?: string) {
33
super(message)
44
this.name = 'WebhookDeploymentConfigurationError'
55
}

‎apps/sim/lib/webhooks/providers/plane.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ async function planeWebhookRequest(
4141
) {
4242
const slug = config.triggerWorkspaceSlug
4343
const apiKey = config.triggerApiKey
44-
if (typeof slug !== 'string' || !slug.trim() || typeof apiKey !== 'string') {
44+
if (
45+
typeof slug !== 'string' ||
46+
!slug.trim() ||
47+
typeof apiKey !== 'string' ||
48+
!apiKey.trim() ||
49+
/[\r\n]/.test(apiKey.trim())
50+
) {
4551
throw new WebhookDeploymentConfigurationError(
4652
'Plane workspace slug and API token are required for automatic registration'
4753
)

‎apps/sim/lib/workflows/executor/resume-execution.ts‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@/lib/billing/core/attribution'
99
import { getJobQueue, shouldExecuteInline } from '@/lib/core/async-jobs'
1010
import type { AsyncExecutionCorrelation } from '@/lib/core/async-jobs/types'
11+
import { logFailureOnce, markFailureKind } from '@/lib/core/errors/failure-log'
1112
import { toTriggerMaxDurationSeconds } from '@/lib/core/execution-limits'
1213
import type { OrchestrationRequestContext } from '@/lib/core/orchestration/types'
1314
import { generateRequestId } from '@/lib/core/utils/request'
@@ -436,16 +437,12 @@ export async function executeResumeWorkflow({
436437
if (error instanceof ResumeWorkflowExecutionError) throw error
437438
const statusCode =
438439
isRecordLike(error) && typeof error.statusCode === 'number' ? error.statusCode : undefined
439-
const diagnostics = projectResolvedSecretDiagnosticError(error, undefined, {
440-
workflowId,
440+
if (statusCode !== undefined && statusCode < 500) markFailureKind(error, 'user')
441+
logFailureOnce(logger, 'Resume request failed', error, {
441442
executionId,
442-
contextId,
443+
metadata: () =>
444+
projectResolvedSecretDiagnosticError(error, undefined, { workflowId, contextId }),
443445
})
444-
if (statusCode !== undefined && statusCode < 500) {
445-
logger.warn('Resume request refused', diagnostics)
446-
} else {
447-
logger.error('Resume request failed', diagnostics)
448-
}
449446
if (statusCode !== undefined) {
450447
throw new ResumeWorkflowExecutionError(statusCode, toError(error).message, statusCode < 500)
451448
}

0 commit comments

Comments
 (0)