{"record":{"id":"fd59f942a5ac8465","repo":"Tencent/WeKnora","slug":"missing-sql-parameter","errorCode":null,"errorMessage":"missing sql parameter","messagePattern":"missing sql parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/database_query.go","lineNumber":140,"sourceCode":"\t}\n\n\t// Parse args from json.RawMessage\n\tvar input DatabaseQueryInput\n\tif err := json.Unmarshal(args, &input); err != nil {\n\t\tlogger.Errorf(ctx, \"[Tool][DatabaseQuery] Failed to parse args: %v\", err)\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   fmt.Sprintf(\"Failed to parse args: %v\", err),\n\t\t}, err\n\t}\n\n\t// Extract SQL from input\n\tif input.SQL == \"\" {\n\t\tlogger.Errorf(ctx, \"[Tool][DatabaseQuery] Missing or invalid SQL parameter\")\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   \"Missing or invalid 'sql' parameter\",\n\t\t}, fmt.Errorf(\"missing sql parameter\")\n\t}\n\n\tlogger.Infof(ctx, \"[Tool][DatabaseQuery] Original SQL query:\\n%s\", input.SQL)\n\tlogger.Infof(ctx, \"[Tool][DatabaseQuery] Tenant ID: %d\", tenantID)\n\n\t// Validate and secure the SQL query\n\tlogger.Debugf(ctx, \"[Tool][DatabaseQuery] Validating and securing SQL...\")\n\tsecuredSQL, err := t.validateAndSecureSQL(input.SQL, tenantID)\n\tif err != nil {\n\t\tlogger.Errorf(ctx, \"[Tool][DatabaseQuery] SQL validation failed: %v\", err)\n\t\treturn &types.ToolResult{\n\t\t\tSuccess: false,\n\t\t\tError:   fmt.Sprintf(\"SQL validation failed: %v\", err),\n\t\t}, err\n\t}\n\n\tlogger.Infof(ctx, \"[Tool][DatabaseQuery] Secured SQL query:\\n%s\", securedSQL)\n\tlogger.Infof(ctx, \"Executing secured SQL query - original: %s, secured: %s, tenant_id: %d\",","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/database_query.go#L122-L158","documentation":"DatabaseQuery tool input validation guard: the parsed args JSON contained an empty 'sql' field, so there is no statement to validate, secure, or execute; the tool rejects the invocation before touching the database.","triggerScenarios":"Thrown at internal/agent/tools/database_query.go:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply a non-empty 'sql' string in the tool arguments","Trim whitespace before the empty check to catch whitespace-only input","Validate required fields in a shared input-validation helper"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}