Tencent/WeKnora · error

attachment %s failed to parse: %s

Error message

attachment %s failed to parse: %s

What it means

The attachment exists and is scoped correctly, but its stored status is TemporaryDocumentStatusFailed — asynchronous parsing failed earlier. The stored ErrorMessage from the failed parse is surfaced to the caller.

Source

Thrown at internal/application/service/temporary_document.go:621

	if len(documentIDs) > 0 {
		perDocumentBudget = temporaryDocumentPromptBudget / len(documentIDs)
	}
	seen := make(map[string]struct{}, len(documentIDs))
	for _, documentID := range documentIDs {
		if _, duplicate := seen[documentID]; duplicate {
			continue
		}
		seen[documentID] = struct{}{}
		document, err := s.repo.GetScoped(ctx, tenantID, sessionID, documentID)
		if err != nil {
			return nil, err
		}
		if document == nil {
			return nil, fmt.Errorf("attachment %s was not found in this session", documentID)
		}
		if document.Status != types.TemporaryDocumentStatusReady {
			if document.Status == types.TemporaryDocumentStatusFailed {
				return nil, fmt.Errorf("attachment %s failed to parse: %s", document.FileName, document.ErrorMessage)
			}
			return nil, fmt.Errorf("attachment %s is still being processed", document.FileName)
		}
		content, selected, total := selectTemporaryDocumentContentWithBudget(document, query, perDocumentBudget)
		result.Attachments = append(result.Attachments, types.MessageAttachment{
			ID: document.ID, URL: document.ResourceRef, FileName: document.FileName,
			FileType: document.FileType, FileSize: document.FileSize, Content: content,
			ContentMode: map[bool]string{true: "full", false: "selected_chunks"}[selected == total],
			TokenCount:  document.TokenCount, SelectedChunks: selected, TotalChunks: total,
		})
		// Image-type attachments always expose their image so vision models can
		// see it directly; text documents only attach extracted images when the
		// question is visual, to avoid gratuitous multimodal latency.
		if docparser.IsImageFormat(document.FileType) || isVisualDocumentQuery(query) {
			for _, image := range temporaryDocumentImageRefs(document.ImageRefs) {
				if image.URL != "" && len(result.ImageURLs) < 4 {
					result.ImageURLs = append(result.ImageURLs, image.URL)
				}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Surface document.ErrorMessage to the user and re-upload a corrected/valid file
  2. Fix the underlying parse failure (valid format, configure ASR model for audio, supported engine)
  3. Check document status (READY) before sending the message
  4. Retry upload if the failure was transient
Defensive patterns

Strategy: validation

Validate before calling

// poll until status resolves before sending message
if doc.Status != types.TemporaryDocumentStatusReady { waitOrAbort() }

Try / catch

if strings.Contains(err.Error(), "failed to parse") {
    // show document.ErrorMessage and prompt re-upload
}

Prevention

When it happens

Trigger: ResolveForPrompt encounters a document whose Status == TemporaryDocumentStatusFailed, i.e. a prior Process/parse failed (bad file, unsupported format, ASR error such as error 560-564) and the failure was persisted.

Common situations: User attaches a file, parsing fails in the background, and the user immediately sends a message referencing it; duplicate attachments (same file uploaded twice concurrently) can also be marked failed.

Understand the failure class

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/fcf515f2672af887. Report an issue: GitHub.