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:
VectorPeak 2026-07-08 09:41:14 +08:00 committed by GitHub
parent 560e6103a9
commit faf7c434fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 6 deletions

View file

@ -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 {

View file

@ -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;
}