{"record":{"id":"064371e6cce29fe2","repo":"Tencent/WeKnora","slug":"failed-to-find-tag-by-seq-id-d-w","errorCode":null,"errorMessage":"failed to find tag by seq_id %d: %w","messagePattern":"failed to find tag by seq_id (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_faq.go","lineNumber":1954,"sourceCode":"}\n\n// hashQuestion 计算问题内容的哈希值，用于生成稳定的 sourceID。\nfunc hashQuestion(question string) string {\n\th := md5.Sum([]byte(question))\n\treturn hex.EncodeToString(h[:4])\n}\n\n// resolveTagID resolves tag ID (UUID) from payload, prioritizing tag_id (seq_id) over tag_name\n// If no tag is specified, creates or finds the \"未分类\" tag\n// Returns the internal UUID of the tag\nfunc (s *knowledgeService) resolveTagID(ctx context.Context, kbID string, payload *types.FAQEntryPayload) (string, error) {\n\ttenantID := ctx.Value(types.TenantIDContextKey).(uint64)\n\n\t// 如果提供了 tag_id (seq_id)，优先使用 tag_id\n\tif payload.TagID != 0 {\n\t\ttag, err := s.tagRepo.GetBySeqID(ctx, tenantID, payload.TagID)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to find tag by seq_id %d: %w\", payload.TagID, err)\n\t\t}\n\t\treturn tag.ID, nil\n\t}\n\n\t// 如果提供了 tag_name，查找或创建标签\n\tif payload.TagName != \"\" {\n\t\ttag, err := s.tagService.FindOrCreateTagByName(ctx, kbID, payload.TagName)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to resolve tag by name '%s': %w\", payload.TagName, err)\n\t\t}\n\t\treturn tag.ID, nil\n\t}\n\n\t// 都没有提供，使用\"未分类\"标签\n\ttag, err := s.tagService.FindOrCreateTagByName(ctx, kbID, types.UntaggedTagName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get or create default untagged tag: %w\", err)\n\t}","sourceCodeStart":1936,"sourceCodeEnd":1972,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_faq.go#L1936-L1972","documentation":"Resolving a tag from its numeric seq_id failed: tagRepo.GetBySeqID errored or found nothing for the tenant, so the FAQ entry cannot be associated with the requested tag and creation/update is aborted.","triggerScenarios":"Thrown at internal/application/service/knowledge_faq.go:1954 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the tag seq_id exists for this tenant","Check tag repository connectivity","Fall back to tag_name resolution when seq_id lookup fails"],"exampleFix":null,"handlingStrategy":"try-catch","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"}