Skip to content

Commit 4a4e07a

Browse files
committed
fix(search): finalize refusal stream contract and validation
1 parent b6a49bc commit 4a4e07a

7 files changed

Lines changed: 33 additions & 17 deletions

File tree

‎apps/sim/app/o/[organizationId]/integrations/live-member-integrations.test.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ vi.mock('@/hooks/queries/organization-secrets', () => ({
1919
useOrganizationSecretSource: () => ({ data: { source: null } }),
2020
}))
2121
vi.mock('@/hooks/queries/search-integrations', () => ({
22-
useSearchIntegrations: () => ({ data: [{ connectorType: 'coda', approved: true }] }),
22+
useSearchIntegrations: () => ({
23+
data: [{ connectorType: 'coda', approved: true }],
24+
isSuccess: true,
25+
}),
2326
}))
2427
vi.mock('@/app/o/[organizationId]/providers/organization-provider', () => organizationProviderMock)
2528
vi.mock('@/app/o/[organizationId]/integrations/disconnect-account-menu', () => ({

‎apps/sim/lib/assistant-actions/tool-permissions.integration.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,8 @@ describe('Assistant action delivery through the durable executor', () => {
902902
])
903903
)
904904
const resultEvent = events.find(
905-
(event) => event.type === 'tool' && event.payload.phase === 'result'
905+
(event) =>
906+
event.type === 'tool' && 'phase' in event.payload && event.payload.phase === 'result'
906907
)
907908
expect(resultEvent?.payload).not.toHaveProperty('error')
908909
}

‎apps/sim/lib/credentials/managed-oauth.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,10 @@ export async function rejectManagedOAuthToken(input: {
374374
}
375375

376376
async function resolveProviderTokenContext(
377-
providerId: string,
377+
providerId: string | null,
378378
token: ResolvedManagedOAuthToken
379379
): Promise<ResolvedManagedOAuthToken> {
380-
if (!isSalesforceOAuthProviderId(providerId)) return token
380+
if (!providerId || !isSalesforceOAuthProviderId(providerId)) return token
381381
const instanceUrl = await fetchSalesforceInstanceUrl(providerId, token.accessToken)
382382
if (!instanceUrl)
383383
throw new ManagedOAuthCredentialError(

‎apps/sim/lib/mothership/request/tools/executor.test.ts‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,10 +1151,6 @@ describe('watchdog completion provenance', () => {
11511151

11521152
await failPendingToolCall(toolCall.id, context, execContext)
11531153
const persisted = completeAsyncToolCall.mock.calls[0][0]
1154-
expect(persisted.result).toEqual({
1155-
__sealedClientToolCompletionV1: expect.any(String),
1156-
__sealedClientToolContextV1: expect.any(String),
1157-
})
11581154
waitForToolConfirmation.mockResolvedValue({
11591155
status: 'error',
11601156
message: persisted.error,
@@ -1391,18 +1387,34 @@ describe('watchdog completion provenance', () => {
13911387
expect(registry.isComplete()).toBe(true)
13921388
})
13931389

1394-
it('retains structural failure compatibility when no provenance registry exists', async () => {
1390+
it('restores a trusted timeout when its writer had no provenance registry', async () => {
13951391
const { toolCall, context } = createHungClient()
13961392

13971393
await failPendingToolCall(toolCall.id, context, { userId: 'user-1' })
13981394

13991395
expect(toolCall.status).toBe('error')
1400-
expect(completeAsyncToolCall).toHaveBeenCalledWith(
1401-
expect.objectContaining({
1402-
result: { error: expect.any(String), outcomeUnknown: true, doNotRetry: true },
1403-
})
1404-
)
1405-
expect(encryptSecret).not.toHaveBeenCalled()
1396+
const persisted = completeAsyncToolCall.mock.calls[0][0]
1397+
waitForToolConfirmation.mockResolvedValue({
1398+
status: 'error',
1399+
message: persisted.error,
1400+
data: persisted.result,
1401+
})
1402+
const completion = await waitForClientToolCompletion({
1403+
toolCallId: toolCall.id,
1404+
runId: context.runId,
1405+
userId: 'user-1',
1406+
timeoutMs: 1,
1407+
registry: new ResolvedSecretTraceRegistry(),
1408+
})
1409+
expect(completion).toEqual({
1410+
status: 'error',
1411+
message: expect.stringContaining('outcome is unknown'),
1412+
data: {
1413+
error: expect.stringContaining('never came back'),
1414+
outcomeUnknown: true,
1415+
doNotRetry: true,
1416+
},
1417+
})
14061418
})
14071419

14081420
it.each([

‎apps/sim/lib/mothership/request/tools/executor.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ async function refuseUnstartedExecution(
770770
toolCallId: toolCall.id,
771771
toolName: toolCall.name,
772772
phase: MothershipStreamV1ToolPhase.result,
773+
executor: MothershipStreamV1ToolExecutor.sim,
774+
mode: MothershipStreamV1ToolMode.async,
773775
status: completion.status,
774776
success: completion.status === 'success',
775777
output: completion.data,

‎scripts/check-explicit-any.baseline.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,6 @@
868868
"apps/sim/tools/salesforce/update_contact.ts": 1,
869869
"apps/sim/tools/salesforce/update_lead.ts": 1,
870870
"apps/sim/tools/salesforce/update_opportunity.ts": 1,
871-
"apps/sim/tools/salesforce/update_task.ts": 1,
872871
"apps/sim/tools/salesforce/utils.ts": 9,
873872
"apps/sim/tools/sentry/events_get.ts": 1,
874873
"apps/sim/tools/sentry/events_list.ts": 2,

‎scripts/check-unused-exports.baseline.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4240,7 +4240,6 @@
42404240
"apps/sim/lib/core/storage/storage.ts#isDatabaseStorage",
42414241
"apps/sim/lib/core/storage/storage.ts#isRedisStorage",
42424242
"apps/sim/lib/core/storage/storage.ts#requireRedis",
4243-
"apps/sim/lib/core/utils/browser-storage.ts#BrowserStorage",
42444243
"apps/sim/lib/core/utils/multipart.ts#MultipartFilePart",
42454244
"apps/sim/lib/core/utils/response-format.ts#hasResponseFormatSelection",
42464245
"apps/sim/lib/core/utils/smooth-bottom-chase.ts#CHASE_REST_GAP",

0 commit comments

Comments
 (0)