mirror of https://github.com/buster-so/buster.git
Refactor import statements and enhance error messages in SQL validation tests
- Simplified import statements in web-search-tool.ts and web-search-tool.test.ts for better readability. - Updated error messages in sql-parser-helpers.test.ts to provide clearer feedback regarding wildcard usage on physical tables.
This commit is contained in:
parent
d438943f9b
commit
7cd3aed6fa
|
@ -17,9 +17,7 @@ describe('webSearch tool', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks();
|
||||
const { mockFirecrawlService: mock } = vi.mocked(
|
||||
await import('@buster/web-tools')
|
||||
) as any;
|
||||
const { mockFirecrawlService: mock } = vi.mocked(await import('@buster/web-tools')) as any;
|
||||
mockFirecrawlService = mock;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
import {
|
||||
FirecrawlService,
|
||||
type WebSearchOptions,
|
||||
type WebSearchResult,
|
||||
} from '@buster/web-tools';
|
||||
import { FirecrawlService, type WebSearchOptions, type WebSearchResult } from '@buster/web-tools';
|
||||
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
||||
import { createTool } from '@mastra/core/tools';
|
||||
import { wrapTraced } from 'braintrust';
|
||||
|
|
|
@ -23,7 +23,8 @@ function createWorkflowAwareHealingMessage(toolName: string, context?: WorkflowC
|
|||
const { currentStep, availableTools } = context;
|
||||
|
||||
const nextMode = currentStep === 'think-and-prep' ? 'analyst' : 'think-and-prep';
|
||||
const transitionDescription = currentStep === 'think-and-prep'
|
||||
const transitionDescription =
|
||||
currentStep === 'think-and-prep'
|
||||
? 'after thinking, understanding the data, and submitting your thoughts'
|
||||
: 'after completing your analysis';
|
||||
|
||||
|
@ -31,7 +32,8 @@ function createWorkflowAwareHealingMessage(toolName: string, context?: WorkflowC
|
|||
if (availableTools && availableTools.size > 0) {
|
||||
const currentToolList = Array.from(availableTools).sort().join(', ');
|
||||
|
||||
const nextModeTools = nextMode === 'analyst'
|
||||
const nextModeTools =
|
||||
nextMode === 'analyst'
|
||||
? 'createMetrics, modifyMetrics, createDashboards, modifyDashboards, doneTool'
|
||||
: 'sequentialThinking, executeSql, respondWithoutAssetCreation, submitThoughts, messageUserClarifyingQuestion';
|
||||
|
||||
|
@ -43,11 +45,13 @@ ${nextModeTools}`;
|
|||
}
|
||||
|
||||
// Fallback to static message if tools not provided
|
||||
const currentModeTools = currentStep === 'think-and-prep'
|
||||
const currentModeTools =
|
||||
currentStep === 'think-and-prep'
|
||||
? 'sequentialThinking, executeSql, respondWithoutAssetCreation, submitThoughts, messageUserClarifyingQuestion'
|
||||
: 'createMetrics, modifyMetrics, createDashboards, modifyDashboards, doneTool';
|
||||
|
||||
const nextModeTools = nextMode === 'analyst'
|
||||
const nextModeTools =
|
||||
nextMode === 'analyst'
|
||||
? 'createMetrics, modifyMetrics, createDashboards, modifyDashboards, doneTool'
|
||||
: 'sequentialThinking, executeSql, respondWithoutAssetCreation, submitThoughts, messageUserClarifyingQuestion';
|
||||
|
||||
|
|
|
@ -426,7 +426,7 @@ models:
|
|||
const sql = 'SELECT * FROM users';
|
||||
const result = validateWildcardUsage(sql);
|
||||
expect(result.isValid).toBe(false);
|
||||
expect(result.error).toContain('Wildcard usage on physical tables is not allowed');
|
||||
expect(result.error).toContain("You're not allowed to use a wildcard on physical tables");
|
||||
expect(result.blockedTables).toContain('users');
|
||||
});
|
||||
|
||||
|
@ -434,7 +434,7 @@ models:
|
|||
const sql = 'SELECT u.* FROM users u';
|
||||
const result = validateWildcardUsage(sql);
|
||||
expect(result.isValid).toBe(false);
|
||||
expect(result.error).toContain('Wildcard usage on physical tables is not allowed');
|
||||
expect(result.error).toContain("You're not allowed to use a wildcard on physical tables");
|
||||
expect(result.blockedTables).toContain('u');
|
||||
});
|
||||
|
||||
|
@ -470,7 +470,7 @@ models:
|
|||
`;
|
||||
const result = validateWildcardUsage(sql);
|
||||
expect(result.isValid).toBe(false);
|
||||
expect(result.error).toContain('Wildcard usage on physical tables is not allowed');
|
||||
expect(result.error).toContain("You're not allowed to use a wildcard on physical tables");
|
||||
expect(result.blockedTables).toContain('users');
|
||||
});
|
||||
|
||||
|
@ -514,7 +514,7 @@ models:
|
|||
const sql = 'SELECT * FROM public.users';
|
||||
const result = validateWildcardUsage(sql);
|
||||
expect(result.isValid).toBe(false);
|
||||
expect(result.error).toContain('Wildcard usage on physical tables is not allowed');
|
||||
expect(result.error).toContain("You're not allowed to use a wildcard on physical tables");
|
||||
});
|
||||
|
||||
it('should handle invalid SQL gracefully', () => {
|
||||
|
|
Loading…
Reference in New Issue