6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (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 / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
98 lines
2.8 KiB
TypeScript
98 lines
2.8 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
|
|
import { loggingSessionMock, workflowAuthzMockFns } from '@sim/testing'
|
|
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const { mockResolveSystemBillingAttribution } = vi.hoisted(() => ({
|
|
mockResolveSystemBillingAttribution: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('@/lib/billing/calculations/usage-monitor', () => ({
|
|
checkServerSideUsageLimits: vi.fn(),
|
|
}))
|
|
vi.mock('@/lib/billing/core/billing-attribution', () => ({
|
|
assertBillingAttributionSnapshot: vi.fn((value) => value),
|
|
checkAttributedUsageLimits: vi.fn(),
|
|
resolveBillingAttribution: vi.fn(),
|
|
resolveSystemBillingAttribution: mockResolveSystemBillingAttribution,
|
|
}))
|
|
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)
|
|
|
|
import { preprocessExecution } from './preprocessing'
|
|
|
|
describe('preprocessExecution webhook correlation logging', () => {
|
|
beforeEach(() => {
|
|
workflowAuthzMockFns.mockGetActiveWorkflowRecord.mockResolvedValue({
|
|
id: 'workflow-1',
|
|
workspaceId: 'workspace-1',
|
|
isDeployed: true,
|
|
})
|
|
})
|
|
|
|
afterAll(() => {
|
|
workflowAuthzMockFns.mockGetActiveWorkflowRecord.mockReset()
|
|
})
|
|
|
|
it('preserves webhook correlation when logging preprocessing failures', async () => {
|
|
mockResolveSystemBillingAttribution.mockRejectedValueOnce(
|
|
new Error('Unable to resolve billing payer')
|
|
)
|
|
|
|
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,
|
|
},
|
|
})
|
|
|
|
expect(loggingSession.safeStart).toHaveBeenCalledWith({
|
|
userId: 'unknown',
|
|
workspaceId: 'workspace-1',
|
|
variables: {},
|
|
triggerData: { correlation },
|
|
})
|
|
})
|
|
})
|