{"record":{"id":"bd98d9ed5be1c678","repo":"Tencent/WeKnora","slug":"query-is-empty-bd98d9","errorCode":null,"errorMessage":"query is empty","messagePattern":"query is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/ollama.go","lineNumber":62,"sourceCode":"\t\tbaseURL: defaultOllamaWebSearchURL, // Hardcoded — not tenant-configurable\n\t\tapiKey:  params.APIKey,\n\t}, nil\n}\n\n// Name returns the provider name\nfunc (p *OllamaProvider) Name() string {\n\treturn \"ollama\"\n}\n\n// Search performs a web search using Ollama Cloud API\nfunc (p *OllamaProvider) Search(\n\tctx context.Context,\n\tquery string,\n\tmaxResults int,\n\tincludeDate bool,\n) ([]*types.WebSearchResult, error) {\n\tif len(query) == 0 {\n\t\treturn nil, fmt.Errorf(\"query is empty\")\n\t}\n\n\tif maxResults <= 0 {\n\t\tmaxResults = defaultOllamaResults\n\t}\n\n\t// Ollama限制最多10个结果\n\tif maxResults > maxOllamaResults {\n\t\tmaxResults = maxOllamaResults\n\t}\n\n\tlogger.Infof(ctx, \"[WebSearch][Ollama] query=%q maxResults=%d url=%s\", query, maxResults, p.baseURL)\n\treq, err := p.buildRequest(ctx, query, maxResults)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresults, err := p.doSearch(ctx, req)\n\tif err != nil {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/ollama.go#L44-L80","documentation":"Input validation at the top of OllamaProvider.Search: the query string has zero length, so there is nothing to send to the Ollama Cloud API. The search aborts before max-results clamping or request building; callers should treat it as a caller-side bug rather than a provider failure.","triggerScenarios":"Thrown at internal/infrastructure/web_search/ollama.go:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure callers supply a non-empty query","Guard the search invocation when the derived query is blank"],"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"}