mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-09 17:19:02 +00:00
fix(core): reject fractional LSP limit inputs (#6455)
* fix(lsp): validate limit as positive integer Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> * fix(lsp): declare limit minimum in schema Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> --------- Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
This commit is contained in:
parent
560e6103a9
commit
faf7c434fc
2 changed files with 32 additions and 6 deletions
|
|
@ -247,7 +247,25 @@ describe('LspTool', () => {
|
|||
filePath: 'src/app.ts',
|
||||
limit: 0,
|
||||
} as LspToolParams);
|
||||
expect(result).toBe('limit must be a positive number.');
|
||||
expect(result).toBe('params/limit must be >= 1');
|
||||
});
|
||||
|
||||
it('rejects negative integer limit', () => {
|
||||
const result = tool.validateToolParams({
|
||||
operation: 'documentSymbol',
|
||||
filePath: 'src/app.ts',
|
||||
limit: -1,
|
||||
} as LspToolParams);
|
||||
expect(result).toBe('params/limit must be >= 1');
|
||||
});
|
||||
|
||||
it('rejects fractional limit', () => {
|
||||
const result = tool.validateToolParams({
|
||||
operation: 'documentSymbol',
|
||||
filePath: 'src/app.ts',
|
||||
limit: 1.5,
|
||||
} as LspToolParams);
|
||||
expect(result).toBe('params/limit must be integer');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1052,6 +1070,17 @@ describe('LspTool', () => {
|
|||
expect(schema.properties?.character?.type).toBe('number');
|
||||
});
|
||||
|
||||
it('limit extension property has integer type', () => {
|
||||
const tool = createTool();
|
||||
const schema = tool.schema.parametersJsonSchema as {
|
||||
properties?: {
|
||||
limit?: { type?: string; minimum?: number };
|
||||
};
|
||||
};
|
||||
expect(schema.properties?.limit?.type).toBe('integer');
|
||||
expect(schema.properties?.limit?.minimum).toBe(1);
|
||||
});
|
||||
|
||||
it('includeDeclaration property has correct type', () => {
|
||||
const tool = createTool();
|
||||
const schema = tool.schema.parametersJsonSchema as {
|
||||
|
|
|
|||
|
|
@ -1081,7 +1081,8 @@ export class LspTool extends BaseDeclarativeTool<LspToolParams, ToolResult> {
|
|||
description: 'Optional LSP server name to target.',
|
||||
},
|
||||
limit: {
|
||||
type: 'number',
|
||||
type: 'integer',
|
||||
minimum: 1,
|
||||
description: 'Optional maximum number of results to return.',
|
||||
},
|
||||
diagnostics: {
|
||||
|
|
@ -1212,10 +1213,6 @@ export class LspTool extends BaseDeclarativeTool<LspToolParams, ToolResult> {
|
|||
if (params.endCharacter !== undefined && params.endCharacter < 1) {
|
||||
return 'endCharacter must be a positive number.';
|
||||
}
|
||||
if (params.limit !== undefined && params.limit <= 0) {
|
||||
return 'limit must be a positive number.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue