Skip to content

fix: #10063 prevent oversized tracing payloads for ByteStream and Ima…#10081

Closed
jovicdev97 wants to merge 0 commit into
deepset-ai:mainfrom
jovicdev97:main
Closed

fix: #10063 prevent oversized tracing payloads for ByteStream and Ima…#10081
jovicdev97 wants to merge 0 commit into
deepset-ai:mainfrom
jovicdev97:main

Conversation

@jovicdev97

Copy link
Copy Markdown

Related Issues

Proposed Changes:

This PR optimizes how ByteStream and ImageContent objects are serialized during tracing to prevent oversized payloads, which fixes #10063

Previously, tracing these objects would attempt to serialize their full binary or base64 content, leading to massive trace sizes. The updated logic in _serializable_value:

ByteStream: Now excludes the raw data payload. Instead, it captures metadata (mime type, size in bytes) and generates a short text preview (first 100 bytes) if the content is text-based.

ImageContent: Now excludes the full base64_image. It captures metadata and provides a truncated preview of the base64 string.

General: Added a helper _get_text_preview to safely decode and truncate text previews.

How did you test it?

I added comprehensive unit tests in test/tracing/test_utils.py covering the following scenarios:

ByteStream Binary: Verifying that large binary data is excluded from serialization while retaining metadata (size_bytes, mime_type).

ByteStream Text: Verifying that text-based streams generate a correct, truncated preview string.

ImageContent: Verifying that large base64 strings are truncated to prevent payload bloat.

Nested Structures: Verifying that these objects are correctly handled when nested inside lists or dictionaries.

Type Coercion: Verifying coerce_tag_value handles these objects correctly via the updated serialization logic.

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@jovicdev97 jovicdev97 requested a review from a team as a code owner November 14, 2025 00:55
@jovicdev97 jovicdev97 requested review from vblagoje and removed request for a team November 14, 2025 00:55
@vercel

vercel Bot commented Nov 14, 2025

Copy link
Copy Markdown

@jovicdev97 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Nov 14, 2025
@sjrl sjrl requested review from sjrl and removed request for vblagoje November 14, 2025 07:06
@LastRemote

Copy link
Copy Markdown
Contributor

Thank you for the quick response!

Have you tested the scenario of a list of ChatMessage with oversized ImageContent? I think that is probably the most important and the most problematic one in terms of tracing. ChatMessage.to_dict() would call ImageContent.to_dict() directly, and that might escape the special handling logic.

@sjrl

sjrl commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

Hey @jovicdev97 thanks for the contribution! However, since this change affects a core part of our tracing functionality, we’d prefer to handle it internally.

If you’d like to explore other ways to contribute, feel free to check out our Contributions Wanted board: Haystack - Contributions wanted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tracing] ByteStream objects cause oversized payloads in tracing backends

3 participants