{"record":{"id":"2b7c9dabff2c6ffa","repo":"Tencent/WeKnora","slug":"enqueue-wiki-ingest-trigger-task-enqueuer-is-nil","errorCode":null,"errorMessage":"enqueue wiki ingest trigger: task enqueuer is nil","messagePattern":"enqueue wiki ingest trigger: task enqueuer is nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/wiki_ingest.go","lineNumber":580,"sourceCode":"\tctx context.Context,\n\ttask interfaces.TaskEnqueuer,\n\ttenantID uint64,\n\tkbID string,\n) error {\n\tlang := types.LanguageFromContextOrDefault(ctx)\n\ttrigger := WikiIngestPayload{\n\t\tTenantID:        tenantID,\n\t\tKnowledgeBaseID: kbID,\n\t\tLanguage:        lang,\n\t}\n\tlangfuse.InjectTracing(ctx, &trigger)\n\ttriggerBytes, err := json.Marshal(trigger)\n\tif err != nil {\n\t\tlogger.Warnf(ctx, \"wiki ingest: failed to marshal trigger task: %v\", err)\n\t\treturn fmt.Errorf(\"marshal wiki ingest trigger: %w\", err)\n\t}\n\tif task == nil {\n\t\treturn errors.New(\"enqueue wiki ingest trigger: task enqueuer is nil\")\n\t}\n\n\tt := asynq.NewTask(types.TypeWikiIngest, triggerBytes,\n\t\tasynq.Queue(types.QueueWiki),\n\t\tasynq.MaxRetry(wikiIngestMaxRetry),\n\t\tasynq.Timeout(60*time.Minute),\n\t\tasynq.ProcessIn(wikiIngestDelay),\n\t)\n\tif _, err := task.Enqueue(t); err != nil {\n\t\tlogger.Warnf(ctx, \"wiki ingest: failed to enqueue trigger task: %v\", err)\n\t\treturn fmt.Errorf(\"enqueue wiki ingest trigger: %w\", err)\n\t}\n\treturn nil\n}\n\n// EnqueueWikiRetract queues a wiki retraction op (a delete cleanup).\n// Identical persistence model as EnqueueWikiIngest — the op rides in\n// task_pending_ops and an asynq trigger fires shortly after to","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/wiki_ingest.go#L562-L598","documentation":"This error is returned by the wiki ingest trigger enqueue helper when the task enqueuer dependency is nil at the moment an ingest trigger task needs to be published to asynq. It is a wiring/initialization guard: without an enqueuer the trigger task cannot be scheduled, so the code fails fast with a descriptive message rather than panicking on a nil interface.","triggerScenarios":"Calling the trigger-enqueue path when the service was constructed without a task enqueuer (nil field), e.g. in a mode or test setup where asynq client wiring was skipped.","commonSituations":"Service constructed with a nil/omitted TaskEnqueuer dependency; running in a mode where async task infrastructure is disabled but a trigger is still requested; miswired dependency injection container.","solutions":["Ensure the wiki ingest service is constructed with a non-nil task enqueuer (asynq client) in the DI wiring.","If triggers are unsupported in the current mode, guard the call site so enqueue is skipped instead of invoked.","Check startup logs/config that enable the async task queue before requests reach the trigger path."],"exampleFix":"// before\nsvc := service.NewWikiIngestService(repo, llm, nil) // enqueuer omitted\n// after\nsvc := service.NewWikiIngestService(repo, llm, taskEnqueuer) // wired asynq client","handlingStrategy":"validation","validationCode":"if enqueuer == nil {\n    return errors.New(\"task enqueuer must be configured before enqueueing wiki triggers\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert all service dependencies are non-nil at construction/startup.","Skip trigger enqueue explicitly when async task mode is disabled.","Cover DI wiring with a smoke test that constructs the service in every supported mode."],"tags":["dependency-injection","async-tasks","nil-check","wiki"],"backgroundTag":"nil-dependency-wiring","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}