Tencent/WeKnora · error

query parameter is required

Error message

query parameter is required

What it means

Argument validation in WebSearchTool.Execute: the parsed WebSearchInput.Query is empty (either absent in the JSON args or an empty string). The guard fires before any network call, returning both a failed ToolResult ('query parameter is required') and this error to signal malformed tool invocation.

Source

Thrown at internal/agent/tools/web_search.go:136

	// Parse args from json.RawMessage
	var input WebSearchInput
	if err := json.Unmarshal(args, &input); err != nil {
		logger.Errorf(ctx, "[Tool][WebSearch] Failed to parse args: %v", err)
		return &types.ToolResult{
			Success: false,
			Error:   fmt.Sprintf("Failed to parse args: %v", err),
		}, err
	}

	// Parse query
	query := input.Query
	ok := query != ""
	if !ok || query == "" {
		logger.Errorf(ctx, "[Tool][WebSearch] Query is required")
		return &types.ToolResult{
			Success: false,
			Error:   "query parameter is required",
		}, fmt.Errorf("query parameter is required")
	}

	logger.Infof(ctx, "[Tool][WebSearch] Searching with query: %s, max_results: %d", query, t.maxResults)

	// Get tenant ID from context
	tenantID := uint64(0)
	if tid, ok := ctx.Value(types.TenantIDContextKey).(uint64); ok {
		tenantID = tid
	}

	if tenantID == 0 {
		logger.Errorf(ctx, "[Tool][WebSearch] Workspace ID not found in context")
		return &types.ToolResult{
			Success: false,
			Error:   "workspace ID not found in context",
		}, fmt.Errorf("workspace ID not found in context")
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Provide a non-empty 'query' in the tool arguments
  2. Validate at input-schema level to reject empty queries earlier
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/agent/tools/web_search.go:136 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/7884bddd6d3a348b. Report an issue: GitHub.