|
1 | 1 | import '@sim/testing/mocks/executor' |
2 | 2 |
|
3 | 3 | import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest' |
| 4 | +import { HarmonicBlock } from '@/blocks/blocks/harmonic' |
4 | 5 | import { KnowledgeBlock } from '@/blocks/blocks/knowledge' |
5 | 6 | import { getBlock } from '@/blocks/index' |
6 | 7 | import { BlockType } from '@/executor/constants' |
@@ -490,6 +491,47 @@ describe('GenericBlockHandler', () => { |
490 | 491 | expect(transform).toHaveBeenCalledTimes(1) |
491 | 492 | }) |
492 | 493 |
|
| 494 | + it('does not expose an invalid resolved Harmonic batch value in handler errors', async () => { |
| 495 | + const resolvedSecret = 'sk-live-invalid-json-secret' |
| 496 | + mockBlock.metadata = { id: 'harmonic', name: 'Harmonic' } |
| 497 | + mockGetBlock.mockReturnValue(HarmonicBlock) |
| 498 | + mockExecuteTool.mockResolvedValue({ |
| 499 | + success: false, |
| 500 | + error: 'Harmonic "personUrns" must be a JSON array', |
| 501 | + }) |
| 502 | + |
| 503 | + const registry = new ResolvedSecretTraceRegistry([ |
| 504 | + { |
| 505 | + name: 'BATCH_IDENTIFIERS', |
| 506 | + plaintext: resolvedSecret, |
| 507 | + encryptedValue: 'encrypted-batch-identifiers', |
| 508 | + }, |
| 509 | + ]) |
| 510 | + registry.recordResolvedAtInputPath('BATCH_IDENTIFIERS', resolvedSecret, ['personUrns']) |
| 511 | + registry.recordResolvedInputProjection(['personUrns'], resolvedSecret, '{{BATCH_IDENTIFIERS}}') |
| 512 | + mockContext.resolvedSecretTraceRegistry = registry |
| 513 | + |
| 514 | + let thrown: unknown |
| 515 | + try { |
| 516 | + await handler.execute(mockContext, mockBlock, { |
| 517 | + operation: 'harmonic_batch_get_people', |
| 518 | + oauthCredential: 'credential-id', |
| 519 | + personUrns: resolvedSecret, |
| 520 | + }) |
| 521 | + } catch (error) { |
| 522 | + thrown = error |
| 523 | + } |
| 524 | + |
| 525 | + expect(thrown).toBeInstanceOf(Error) |
| 526 | + expect((thrown as Error).message).toBe('Harmonic "personUrns" must be a JSON array') |
| 527 | + expect((thrown as Error).message).not.toContain(resolvedSecret) |
| 528 | + expect(mockExecuteTool).toHaveBeenCalledWith( |
| 529 | + 'some_custom_tool', |
| 530 | + expect.objectContaining({ personUrns: resolvedSecret }), |
| 531 | + { executionContext: mockContext } |
| 532 | + ) |
| 533 | + }) |
| 534 | + |
493 | 535 | it('should throw error if the associated tool is not found', async () => { |
494 | 536 | const inputs = { param1: 'value' } |
495 | 537 |
|
|
0 commit comments