{"record":{"id":"157ef9d49d76a7fb","repo":"Tencent/WeKnora","slug":"attachment-s-is-still-being-processed","errorCode":null,"errorMessage":"attachment %s is still being processed","messagePattern":"attachment (.+?) is still being processed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/application/service/temporary_document.go","lineNumber":623,"sourceCode":"\t}\n\tseen := make(map[string]struct{}, len(documentIDs))\n\tfor _, documentID := range documentIDs {\n\t\tif _, duplicate := seen[documentID]; duplicate {\n\t\t\tcontinue\n\t\t}\n\t\tseen[documentID] = struct{}{}\n\t\tdocument, err := s.repo.GetScoped(ctx, tenantID, sessionID, documentID)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif document == nil {\n\t\t\treturn nil, fmt.Errorf(\"attachment %s was not found in this session\", documentID)\n\t\t}\n\t\tif document.Status != types.TemporaryDocumentStatusReady {\n\t\t\tif document.Status == types.TemporaryDocumentStatusFailed {\n\t\t\t\treturn nil, fmt.Errorf(\"attachment %s failed to parse: %s\", document.FileName, document.ErrorMessage)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"attachment %s is still being processed\", document.FileName)\n\t\t}\n\t\tcontent, selected, total := selectTemporaryDocumentContentWithBudget(document, query, perDocumentBudget)\n\t\tresult.Attachments = append(result.Attachments, types.MessageAttachment{\n\t\t\tID: document.ID, URL: document.ResourceRef, FileName: document.FileName,\n\t\t\tFileType: document.FileType, FileSize: document.FileSize, Content: content,\n\t\t\tContentMode: map[bool]string{true: \"full\", false: \"selected_chunks\"}[selected == total],\n\t\t\tTokenCount:  document.TokenCount, SelectedChunks: selected, TotalChunks: total,\n\t\t})\n\t\t// Image-type attachments always expose their image so vision models can\n\t\t// see it directly; text documents only attach extracted images when the\n\t\t// question is visual, to avoid gratuitous multimodal latency.\n\t\tif docparser.IsImageFormat(document.FileType) || isVisualDocumentQuery(query) {\n\t\t\tfor _, image := range temporaryDocumentImageRefs(document.ImageRefs) {\n\t\t\t\tif image.URL != \"\" && len(result.ImageURLs) < 4 {\n\t\t\t\t\tresult.ImageURLs = append(result.ImageURLs, image.URL)\n\t\t\t\t}\n\t\t\t}\n\t\t}","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/temporary_document.go#L605-L641","documentation":"The attachment exists but its status is neither Ready nor Failed — asynchronous processing has not finished yet, so there is no parsed content to resolve into the prompt. The error reports the file name.","triggerScenarios":"ResolveForPrompt is called while the document's async parse (Process) is still running — Status is PENDING/PROCESSING rather than TemporaryDocumentStatusReady.","commonSituations":"Client sends the chat message immediately after upload without waiting for the parse-complete callback/WS event; large documents that take a long time to parse; queue backlog delaying processing.","solutions":["Wait for the document status to become READY (poll or subscribe to processing events) before sending the message","Add client-side gating that disables sending until all attachments are ready","Implement retry-with-backoff on ResolveForPrompt until the document completes","Investigate parser queue throughput if processing is persistently slow"],"exampleFix":"// before\nresult, err := svc.ResolveForPrompt(ctx, tenantID, sessionID, ids, query)\n// after\nwaitUntilReady(ctx, svc, tenantID, sessionID, ids) // poll status == READY\nresult, err := svc.ResolveForPrompt(ctx, tenantID, sessionID, ids, query)","handlingStrategy":"retry","validationCode":"doc, _ := repo.GetScoped(ctx, tenantID, sessionID, documentID)\nif doc != nil && doc.Status != types.TemporaryDocumentStatusReady { /* wait */ }","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"still being processed\") {\n    time.Sleep(backoff) // retry ResolveForPrompt with backoff until READY\n}","preventionTips":["Wait for parse-complete events before sending messages","Gate the send button until all attachments are READY","Apply exponential backoff retries"],"tags":["async","race-condition","attachment-processing"],"backgroundTag":"resource-not-ready","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}