{"record":{"id":"135935e3ddc52cda","repo":"Tencent/WeKnora","slug":"web-search-provider-not-found","errorCode":null,"errorMessage":"web search provider not found","messagePattern":"web search provider not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/web_search_provider.go","lineNumber":85,"sourceCode":"\t\t}\n\t}\n\n\tlogger.Infof(ctx, \"Updating web search provider: tenant=%d, id=%s\", provider.TenantID, provider.ID)\n\treturn s.repo.Update(ctx, provider)\n}\n\n// UpdateProviderCredentials writes the api_key credential field. Web search\n// providers are stateless from our side — every search call rebuilds a\n// transport from current Parameters — so no cache invalidation is required.\nfunc (s *webSearchProviderService) UpdateProviderCredentials(\n\tctx context.Context, tenantID uint64, id string, apiKey *string,\n) (*types.WebSearchProviderEntity, error) {\n\texisting, err := s.repo.GetByID(ctx, tenantID, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif existing == nil {\n\t\treturn nil, fmt.Errorf(\"web search provider not found\")\n\t}\n\n\tif apiKey != nil && *apiKey != \"\" && *apiKey != existing.Parameters.APIKey {\n\t\texisting.Parameters.APIKey = *apiKey\n\t\tif err := s.repo.Update(ctx, existing); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlogger.Infof(ctx, \"WebSearch provider credentials updated: tenant=%d id=%s\", tenantID, id)\n\t}\n\treturn existing, nil\n}\n\n// ClearProviderCredential clears the api_key credential. Idempotent.\nfunc (s *webSearchProviderService) ClearProviderCredential(\n\tctx context.Context, tenantID uint64, id, field string,\n) error {\n\tif field != \"api_key\" {\n\t\treturn fmt.Errorf(\"unknown credential field: %s\", field)","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/web_search_provider.go#L67-L103","documentation":"Lookup guard in UpdateProviderCredentials: the tenant-scoped GetByID for the web search provider ID returned nil, so there is no provider record to write the API key onto. It fires when the ID is wrong or belongs to another workspace; unlike a repo error, this specifically means 'not found' rather than 'lookup failed'.","triggerScenarios":"Thrown at internal/application/service/web_search_provider.go:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the provider ID and tenant match an existing row","Refresh the client's provider list (entity may have been deleted)","Recreate the provider before setting credentials"],"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"}