d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
92 lines
2.5 KiB
TypeScript
92 lines
2.5 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
|
|
import { loggingSessionMock } from '@sim/testing'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
const { mockGetWorkspaceBilledAccountUserId } = vi.hoisted(() => ({
|
|
mockGetWorkspaceBilledAccountUserId: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('@sim/db', () => ({ db: {} }))
|
|
vi.mock('drizzle-orm', () => ({ eq: vi.fn() }))
|
|
vi.mock('@/lib/billing/calculations/usage-monitor', () => ({
|
|
checkServerSideUsageLimits: vi.fn(),
|
|
}))
|
|
vi.mock('@/lib/billing/core/subscription', () => ({
|
|
getHighestPrioritySubscription: vi.fn(),
|
|
}))
|
|
vi.mock('@/lib/core/execution-limits', () => ({
|
|
getExecutionTimeout: vi.fn(() => 0),
|
|
}))
|
|
vi.mock('@/lib/core/rate-limiter/rate-limiter', () => ({
|
|
RateLimiter: vi.fn(),
|
|
}))
|
|
vi.mock('@/lib/logs/execution/logging-session', () => loggingSessionMock)
|
|
vi.mock('@/lib/workspaces/utils', () => ({
|
|
getWorkspaceBilledAccountUserId: mockGetWorkspaceBilledAccountUserId,
|
|
}))
|
|
|
|
vi.mock('@sim/platform-authz/workflow', () => ({
|
|
getActiveWorkflowRecord: vi.fn().mockResolvedValue({
|
|
id: 'workflow-1',
|
|
workspaceId: 'workspace-1',
|
|
isDeployed: true,
|
|
}),
|
|
}))
|
|
|
|
import { preprocessExecution } from './preprocessing'
|
|
|
|
describe('preprocessExecution webhook correlation logging', () => {
|
|
it('preserves webhook correlation when logging preprocessing failures', async () => {
|
|
mockGetWorkspaceBilledAccountUserId.mockResolvedValueOnce(null)
|
|
|
|
const loggingSession = {
|
|
safeStart: vi.fn().mockResolvedValue(true),
|
|
safeCompleteWithError: vi.fn().mockResolvedValue(undefined),
|
|
}
|
|
|
|
const correlation = {
|
|
executionId: 'execution-webhook-1',
|
|
requestId: 'request-webhook-1',
|
|
source: 'webhook' as const,
|
|
workflowId: 'workflow-1',
|
|
webhookId: 'webhook-1',
|
|
path: 'incoming/slack',
|
|
provider: 'slack',
|
|
triggerType: 'webhook',
|
|
}
|
|
|
|
const result = await preprocessExecution({
|
|
workflowId: 'workflow-1',
|
|
userId: 'unknown',
|
|
triggerType: 'webhook',
|
|
executionId: 'execution-webhook-1',
|
|
requestId: 'request-webhook-1',
|
|
loggingSession: loggingSession as any,
|
|
triggerData: { correlation },
|
|
workflowRecord: {
|
|
id: 'workflow-1',
|
|
workspaceId: 'workspace-1',
|
|
isDeployed: true,
|
|
} as any,
|
|
})
|
|
|
|
expect(result).toMatchObject({
|
|
success: false,
|
|
error: {
|
|
statusCode: 500,
|
|
logCreated: true,
|
|
},
|
|
})
|
|
|
|
expect(loggingSession.safeStart).toHaveBeenCalledWith({
|
|
userId: 'unknown',
|
|
workspaceId: 'workspace-1',
|
|
variables: {},
|
|
triggerData: { correlation },
|
|
})
|
|
})
|
|
})
|