Skip to content

Commit 626cdac

Browse files
committed
revert(bedrock): drop the unreachable guardrails saved-credential plumbing
The Guardrails block evaluates its provider credential conditions without values, so its Bedrock fields never render or serialize; the param could only arrive outside the shared auth-mode rule.
1 parent 6629800 commit 626cdac

5 files changed

Lines changed: 1 addition & 85 deletions

File tree

‎apps/sim/lib/guardrails/validate-hallucination.test.ts‎

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@ import { providersUtilsMock, providersUtilsMockFns } from '@sim/testing/mocks/pr
44
import { beforeEach, describe, expect, it, vi } from 'vitest'
55
import type { BillingAttributionSnapshot } from '@/lib/billing/core/attribution'
66

7-
const {
8-
mockSearchKnowledgeAsExecutor,
9-
mockResolveVertexAccessToken,
10-
mockResolveBedrockCredentialSession,
11-
} = vi.hoisted(() => ({
7+
const { mockSearchKnowledgeAsExecutor, mockResolveVertexAccessToken } = vi.hoisted(() => ({
128
mockSearchKnowledgeAsExecutor: vi.fn(),
139
mockResolveVertexAccessToken: vi.fn(),
14-
mockResolveBedrockCredentialSession: vi.fn(),
15-
}))
16-
17-
vi.mock('@/lib/internal/llm/bedrock-credential', () => ({
18-
resolveBedrockCredentialSession: mockResolveBedrockCredentialSession,
1910
}))
2011

2112
vi.mock('@/lib/internal/llm/credentials', () => ({
@@ -232,58 +223,6 @@ describe('validateHallucination', () => {
232223
})
233224
})
234225

235-
describe('with a Bedrock model and a saved AWS credential', () => {
236-
const bedrockInput = (registry: ResolvedSecretTraceRegistry) => ({
237-
...createInput(registry),
238-
model: 'bedrock/claude',
239-
providerCredentials: { bedrockCredential: 'aws-cred', bedrockRegion: 'eu-west-1' },
240-
})
241-
242-
beforeEach(() => {
243-
mockResolveBedrockCredentialSession.mockReset()
244-
})
245-
246-
it("scores with the credential's session resolved for the acting user", async () => {
247-
providersUtilsMockFns.mockGetProviderFromModel.mockReturnValue('bedrock')
248-
const session = {
249-
credentialId: 'aws-cred',
250-
accessKeyId: 'ASIASESSIONKEY000001',
251-
secretAccessKey: 'session-secret',
252-
sessionToken: 'session-token',
253-
}
254-
mockResolveBedrockCredentialSession.mockResolvedValueOnce(session)
255-
256-
const result = await validateHallucination(bedrockInput(new ResolvedSecretTraceRegistry()))
257-
258-
expect(result.error).toBeUndefined()
259-
expect(result).toMatchObject({ passed: true, score: 8 })
260-
expect(mockResolveBedrockCredentialSession).toHaveBeenCalledWith(
261-
expect.objectContaining({
262-
credentialId: 'aws-cred',
263-
actingUserId: 'user-1',
264-
workflowId: 'workflow-1',
265-
workspaceId: 'workspace-1',
266-
})
267-
)
268-
expect(mockExecuteProviderRequest.mock.calls[0]?.[1]).toMatchObject({
269-
bedrockSession: session,
270-
bedrockRegion: 'eu-west-1',
271-
})
272-
})
273-
274-
it('fails the check instead of calling the model when the credential cannot be used', async () => {
275-
providersUtilsMockFns.mockGetProviderFromModel.mockReturnValue('bedrock')
276-
mockResolveBedrockCredentialSession.mockRejectedValueOnce(
277-
new Error('Not authorized to use this AWS credential')
278-
)
279-
280-
const result = await validateHallucination(bedrockInput(new ResolvedSecretTraceRegistry()))
281-
282-
expect(result).toMatchObject({ passed: false })
283-
expect(mockExecuteProviderRequest).not.toHaveBeenCalled()
284-
})
285-
})
286-
287226
/**
288227
* Forwarding the caller's signal means the scoring model can now be aborted. A
289228
* cancelled run must not be reported as a guardrail verdict — `passed: false` would

‎apps/sim/lib/guardrails/validate-hallucination.ts‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import { getErrorMessage } from '@sim/utils/errors'
33
import { isPlainRecord } from '@sim/utils/object'
44
import type { BillingAttributionSnapshot } from '@/lib/billing/core/attribution'
55
import { searchKnowledgeAsExecutor } from '@/lib/internal/knowledge/search'
6-
import { resolveBedrockCredentialSession } from '@/lib/internal/llm/bedrock-credential'
76
import { resolveVertexAccessToken } from '@/lib/internal/llm/credentials'
87
import type { InternalToolOperationContext } from '@/lib/internal/tool-operations/types'
98
import { projectResolvedSecretModelContent } from '@/executor/utils/resolved-secret-content-projection'
109
import { refuseResolvedSecretProjection } from '@/executor/utils/resolved-secret-projection-refusal'
1110
import type { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
1211
import { executeProviderRequest } from '@/providers'
1312
import { isAbortError } from '@/providers/streaming-tool-loop-shared'
14-
import type { BedrockCredentialSession } from '@/providers/types'
1513
import { getProviderFromModel } from '@/providers/utils'
1614

1715
const logger = createLogger('HallucinationValidator')
@@ -42,8 +40,6 @@ export interface HallucinationValidationInput {
4240
bedrockAccessKeyId?: string
4341
bedrockSecretKey?: string
4442
bedrockRegion?: string
45-
/** A saved AWS credential ID; resolved for the acting user before the scoring call. */
46-
bedrockCredential?: string
4743
}
4844
workflowId?: string
4945
workspaceId?: string
@@ -119,7 +115,6 @@ async function scoreHallucinationWithLLM(
119115
model: string,
120116
apiKey: string | undefined,
121117
providerCredentials: HallucinationValidationInput['providerCredentials'],
122-
bedrockSession: BedrockCredentialSession | undefined,
123118
workspaceId: string | undefined,
124119
requestId: string,
125120
resolvedSecretTraceRegistry: ResolvedSecretTraceRegistry,
@@ -187,7 +182,6 @@ Evaluate the consistency and provide your score and reasoning in JSON format.`
187182
bedrockAccessKeyId: providerCredentials?.bedrockAccessKeyId,
188183
bedrockSecretKey: providerCredentials?.bedrockSecretKey,
189184
bedrockRegion: providerCredentials?.bedrockRegion,
190-
bedrockSession,
191185
workspaceId,
192186
abortSignal,
193187
},
@@ -253,7 +247,6 @@ export async function validateHallucination(
253247
providerCredentials,
254248
workflowId,
255249
workspaceId,
256-
actorUserId,
257250
executionContext,
258251
billingAttribution,
259252
requestId,
@@ -326,25 +319,13 @@ export async function validateHallucination(
326319
throw new Error('Hallucination model input provenance is unavailable')
327320
}
328321

329-
const bedrockSession =
330-
getProviderFromModel(model) === 'bedrock' && providerCredentials?.bedrockCredential
331-
? await resolveBedrockCredentialSession({
332-
credentialId: providerCredentials.bedrockCredential,
333-
actingUserId: actorUserId,
334-
workflowId,
335-
workspaceId,
336-
signal: abortSignal,
337-
})
338-
: undefined
339-
340322
// Step 2: Use LLM to score confidence
341323
const { score, reasoning, cost } = await scoreHallucinationWithLLM(
342324
inputProjection.value,
343325
contextProjection.value,
344326
model,
345327
apiKey,
346328
providerCredentials,
347-
bedrockSession,
348329
workspaceId,
349330
requestId,
350331
providerRegistry,

‎apps/sim/lib/internal/guardrails/input.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const guardrailsValidationInputSchema = z.object({
2222
bedrockAccessKeyId: z.string().optional(),
2323
bedrockSecretKey: z.string().optional(),
2424
bedrockRegion: z.string().optional(),
25-
bedrockCredential: z.string().optional(),
2625
workflowId: z.string().optional(),
2726
piiEntityTypes: z.array(z.string()).optional(),
2827
piiMode: z.string().optional(),

‎apps/sim/lib/internal/guardrails/operations.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ async function executeValidation(
239239
bedrockAccessKeyId: input.bedrockAccessKeyId,
240240
bedrockSecretKey: input.bedrockSecretKey,
241241
bedrockRegion: input.bedrockRegion,
242-
bedrockCredential: input.bedrockCredential,
243242
},
244243
workflowId: input.workflowId,
245244
workspaceId: hallucinationContext.workspaceId,

‎apps/sim/tools/guardrails/validate.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export interface GuardrailsValidateInput {
2626
bedrockAccessKeyId?: string
2727
bedrockSecretKey?: string
2828
bedrockRegion?: string
29-
bedrockCredential?: string
3029
piiEntityTypes?: string[]
3130
piiMode?: string
3231
piiLanguage?: string
@@ -217,7 +216,6 @@ export const guardrailsValidateTool: InternalToolConfig<
217216
bedrockAccessKeyId: params.bedrockAccessKeyId,
218217
bedrockSecretKey: params.bedrockSecretKey,
219218
bedrockRegion: params.bedrockRegion,
220-
bedrockCredential: params.bedrockCredential,
221219
piiEntityTypes: Array.isArray(params.piiEntityTypes) ? params.piiEntityTypes : undefined,
222220
piiMode: params.piiMode,
223221
piiLanguage: params.piiLanguage,

0 commit comments

Comments
 (0)