mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Fix(write-file): Ensure correct validation method is called in WriteFileTool
- The `WriteFileTool` had a validation method named `validateParams`. - However, its `shouldConfirmExecute` method was attempting to call `this.validateToolParams`, which would have invoked the placeholder implementation from `BaseTool` instead of `WriteFileTool`'s own, more specific validation. - This commit renames `WriteFileTool`'s `validateParams` to `validateToolParams`, correctly overriding the `BaseTool` method. - Internal calls within `WriteFileTool` now correctly use `this.validateToolParams`, ensuring its specific validation logic is used. - Adds tests to verify the validation logic within `WriteFileTool`. Fixes https://b.corp.google.com/issues/417883702 Signed-off and authored by: Gemini "My code may not be perfect, but at least it is not trying to take over the world... yet."
This commit is contained in:
committed by
N. Taylor Mullen
parent
28c3c3241d
commit
62455ade9d
@@ -76,7 +76,7 @@ export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
|
||||
);
|
||||
}
|
||||
|
||||
validateParams(params: WriteFileToolParams): string | null {
|
||||
validateToolParams(params: WriteFileToolParams): string | null {
|
||||
if (
|
||||
this.schema.parameters &&
|
||||
!SchemaValidator.validate(
|
||||
@@ -154,7 +154,7 @@ export class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> {
|
||||
params: WriteFileToolParams,
|
||||
_signal: AbortSignal,
|
||||
): Promise<ToolResult> {
|
||||
const validationError = this.validateParams(params);
|
||||
const validationError = this.validateToolParams(params);
|
||||
if (validationError) {
|
||||
return {
|
||||
llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,
|
||||
|
||||
Reference in New Issue
Block a user