Tencent/WeKnora · error

API key is required for Ollama provider

Error message

API key is required for Ollama provider

What it means

Constructor validation in NewOllamaProvider: params.APIKey is empty, but the Ollama Cloud web search API requires a key. The provider refuses construction, preventing an unauthenticated call to the hardcoded (SSRF-safe) ollama.com endpoint from ever being attempted.

Source

Thrown at internal/infrastructure/web_search/ollama.go:36

	// defaultOllamaWebSearchURL is the hardcoded Ollama web search API URL.
	// Not configurable by tenants — prevents SSRF.
	defaultOllamaWebSearchURL = "https://ollama.com/api/web_search"
	defaultOllamaTimeout      = 10 * time.Second
	defaultOllamaResults      = 5
	maxOllamaResults          = 10 // Ollama限制最多10个结果
)

// OllamaProvider implements web search using Ollama Cloud API
type OllamaProvider struct {
	client  *http.Client
	baseURL string
	apiKey  string
}

// NewOllamaProvider creates a new Ollama web search provider from parameters.
func NewOllamaProvider(params types.WebSearchProviderParameters) (interfaces.WebSearchProvider, error) {
	if params.APIKey == "" {
		return nil, fmt.Errorf("API key is required for Ollama provider")
	}
	client, err := NewSearchHTTPClient(defaultOllamaTimeout, params.ProxyURL)
	if err != nil {
		return nil, fmt.Errorf("create Ollama HTTP client: %w", err)
	}
	return &OllamaProvider{
		client:  client,
		baseURL: defaultOllamaWebSearchURL, // Hardcoded — not tenant-configurable
		apiKey:  params.APIKey,
	}, nil
}

// Name returns the provider name
func (p *OllamaProvider) Name() string {
	return "ollama"
}

// Search performs a web search using Ollama Cloud API

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Configure the Ollama API key in the tenant's provider settings
  2. Select another search provider if no Ollama credentials exist
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/infrastructure/web_search/ollama.go:36 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/59b3d1d32321262b. Report an issue: GitHub.