This commit is contained in:
@@ -53,6 +53,14 @@ describe('sanitizeQuery', () => {
|
||||
it('preserves public IPs', () => {
|
||||
expect(sanitizeQuery('query 8.8.8.8 dns', {})).toBe('query 8.8.8.8 dns');
|
||||
});
|
||||
it('returns null for missing / non-string query instead of throwing', () => {
|
||||
// 退行したモデルが query なしの WebSearch を吐くと undefined が渡ってくる
|
||||
expect(sanitizeQuery(undefined as unknown as string, {})).toBeNull();
|
||||
expect(sanitizeQuery(null as unknown as string, {})).toBeNull();
|
||||
expect(sanitizeQuery(123 as unknown as string, {})).toBeNull();
|
||||
expect(sanitizeQuery('', {})).toBeNull();
|
||||
expect(sanitizeQuery(' ', {})).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('web tools', () => {
|
||||
@@ -148,6 +156,17 @@ describe('web tools', () => {
|
||||
expect(fs.existsSync(path.join(workspacePath, 'logs', 'webfetch-screenshots'))).toBe(false);
|
||||
});
|
||||
|
||||
it('returns a friendly error (not a crash) when WebSearch query is missing', async () => {
|
||||
workspacePath = makeWorkspace();
|
||||
|
||||
// 引数欠落のツール呼び出し(退行モデル由来)でジョブ全体を巻き添えにしない
|
||||
const result = await executeTool('WebSearch', {}, makeContext(workspacePath));
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.isError).toBe(true);
|
||||
expect(result?.output).toContain('query');
|
||||
});
|
||||
|
||||
it('records invalid URL attempts before fetch', async () => {
|
||||
workspacePath = makeWorkspace();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user