Tencent/WeKnora · error
tenant repository is unavailable
Error message
tenant repository is unavailable
What it means
Sentinel guard in restoreSummaryRefreshTenantInfo: the injected TenantRepository is nil, so the worker cannot rebuild the full tenant context (TenantInfoContextKey) required by the retrieve-engine factory when reindexing a summary chunk. A wiring/dependency-injection defect at startup, not a runtime data fault.
Source
Thrown at internal/application/service/knowledge_summary_refresh.go:68
if latestChunk.ContentRevision != sourceChunk.ContentRevision ||
latestChunk.IsEnabled != sourceChunk.IsEnabled {
return true, nil
}
}
return false, nil
}
// restoreSummaryRefreshTenantInfo rebuilds the tenant context normally added
// by the HTTP authentication middleware. Summary refreshes run in an Asynq
// worker, and the retrieve-engine factory needs the full tenant configuration,
// not only TenantIDContextKey, when it reindexes the summary chunk.
func restoreSummaryRefreshTenantInfo(
ctx context.Context,
tenantRepo interfaces.TenantRepository,
tenantID uint64,
) (context.Context, error) {
if tenantRepo == nil {
return ctx, fmt.Errorf("tenant repository is unavailable")
}
tenant, err := tenantRepo.GetTenantByID(ctx, tenantID)
if err != nil {
return ctx, fmt.Errorf("get tenant %d for summary refresh: %w", tenantID, err)
}
if tenant == nil {
return ctx, fmt.Errorf("tenant %d not found for summary refresh", tenantID)
}
return context.WithValue(ctx, types.TenantInfoContextKey, tenant), nil
}
// enqueueSummaryRefresh marks an existing summary as queued and enqueues an
// independent refresh task. The pending status is written before Enqueue
// because the Lite executor may run the task synchronously inside Enqueue.
func enqueueSummaryRefresh(
ctx context.Context,
repo interfaces.KnowledgeRepository,
taskEnqueuer interfaces.TaskEnqueuer,View on GitHub (pinned to 988cbb0330)
Solutions
- Fix service construction to inject a non-nil TenantRepository into the summary-refresh worker
- Add a startup sanity check that fails fast on missing dependencies
- Cover the wiring with a DI/unit test (see TestRestoreSummaryRefreshTenantInfo)
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/application/service/knowledge_summary_refresh.go:68 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/c4001d3f373ab784.
Report an issue: GitHub.