{"record":{"id":"01d653ef9bef6fa2","repo":"Tencent/WeKnora","slug":"tenant-id-is-required","errorCode":null,"errorMessage":"tenant ID is required","messagePattern":"tenant ID is required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/web_search_provider.go","lineNumber":26,"sourceCode":"\t\"github.com/Tencent/WeKnora/internal/logger\"\n\t\"github.com/Tencent/WeKnora/internal/types\"\n\t\"github.com/Tencent/WeKnora/internal/types/interfaces\"\n)\n\n// webSearchProviderService implements interfaces.WebSearchProviderService\ntype webSearchProviderService struct {\n\trepo interfaces.WebSearchProviderRepository\n}\n\n// NewWebSearchProviderService creates a new web search provider service\nfunc NewWebSearchProviderService(repo interfaces.WebSearchProviderRepository) interfaces.WebSearchProviderService {\n\treturn &webSearchProviderService{repo: repo}\n}\n\n// CreateProvider creates a new web search provider configuration.\nfunc (s *webSearchProviderService) CreateProvider(ctx context.Context, provider *types.WebSearchProviderEntity) error {\n\tif provider.TenantID == 0 {\n\t\treturn fmt.Errorf(\"tenant ID is required\")\n\t}\n\n\tif !isValidProviderType(provider.Provider) {\n\t\treturn fmt.Errorf(\"invalid provider type: %s\", provider.Provider)\n\t}\n\n\tif err := validateProviderParameters(provider.Provider, provider.Parameters); err != nil {\n\t\treturn err\n\t}\n\n\tif provider.IsDefault {\n\t\tif err := s.repo.ClearDefault(ctx, provider.TenantID, \"\"); err != nil {\n\t\t\tlogger.Warnf(ctx, \"Failed to clear default providers: %v\", err)\n\t\t}\n\t}\n\n\tlogger.Infof(ctx, \"Creating web search provider: tenant=%d, name=%s, type=%s\", provider.TenantID, provider.Name, provider.Provider)\n\treturn s.repo.Create(ctx, provider)","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/web_search_provider.go#L8-L44","documentation":"CreateProvider (web search provider service) requires a non-zero tenant ID since provider entities are tenant-scoped; a zero value means the caller lacks workspace context. Pure input guard before touching the repository.","triggerScenarios":"Thrown at internal/application/service/web_search_provider.go:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the authenticated tenant ID into CreateProvider","Ensure tenant context middleware runs before the handler","Return 400/401 so the client authenticates properly"],"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"}