Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DatabaseSync } from 'node:sqlite'
import { expect, test } from 'vitest'
import { McpCallerError } from '#mcp/caller-error.ts'
import { createMcpCallerContext } from '#mcp/context.ts'
import { createD1FromSqlite } from '#worker/test-support/create-d1-from-sqlite.ts'
import { applyAllMigrations as applyRepositoryMigrations } from '#worker/test-support/apply-all-migrations.ts'
Expand Down Expand Up @@ -164,7 +165,26 @@ test('mergeIntegrationConfig and integration_save create a new app + connection
},
{ env: createEnv().env, callerContext: caller('user-123') },
),
).rejects.toThrow(/missing or invalid required fields/i)
).rejects.toThrow(McpCallerError)

await expect(
integrationSaveCapability.handler(
{
name: 'slack',
tokenUrl: 'https://slack.com/api/oauth.v2.access',
flow: 'confidential',
clientId: 'slack-client-id',
// accessTokenSecretName omitted — create requires it
},
{ env: createEnv().env, callerContext: caller('user-123') },
),
).rejects.toSatisfy(
(error: unknown) =>
error instanceof McpCallerError &&
/Cannot create integration "slack".*accessTokenSecretName/i.test(
error.message,
),
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
})

test('integration_save reuses an existing app when credentials match and preserves unspecified fields on partial update', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineDomainCapability } from '#mcp/capabilities/define-domain-capabili
import { capabilityDomainNames } from '#mcp/capabilities/domain-metadata.ts'
import { requireMcpUser } from '#mcp/capabilities/meta/require-user.ts'
import { type CapabilityContext } from '#mcp/capabilities/types.ts'
import { McpCallerError } from '#mcp/caller-error.ts'
import {
getIntegration,
upsertIntegration,
Expand Down Expand Up @@ -90,7 +91,9 @@ function createNewIntegrationConfig(
return `${field}: ${issue.message}`
})
.join(', ')
throw new Error(
// Create-time field gaps are caller-fixable (agents omit required
// secrets names); keep them off Sentry via McpCallerError.
throw new McpCallerError(
`Cannot create integration "${args.name}": missing or invalid required fields — ${details}`,
)
}
Expand Down
Loading