Skip to content

Conversation

@yaricom
Copy link
Contributor

@yaricom yaricom commented Dec 4, 2025

Details

Adding attachment extraction logic from input/output data of the logged span/trace objects to reduce load on the backend.

Change checklist

  • User facing
  • Documentation update

Issues

  • Resolves #
  • OPIK-2927

Testing

Implemented related unit tests

Documentation

- Introduced `AttachmentDecoder` abstract base class for decoding attachment data.
- Added `decoder_helpers` with MIME type detection and file extension utility functions.
- Implemented `Base64AttachmentDecoder` for decoding base64-encoded data into `Attachment` objects with MIME-type inspection and file generation logic.
@github-actions github-actions bot added python Pull requests that update Python code Python SDK labels Dec 4, 2025
@yaricom yaricom added work in progress and removed python Pull requests that update Python code Python SDK labels Dec 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

SDK E2E Tests Results

135 tests  ±0   133 ✅ ±0   2m 47s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     2 ❌ ±0 

For more details on these failures, see this check.

Results for commit 2e3b847. ± Comparison against base commit 363f146.

This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.
tests.e2e.test_tracing ‑ test_opik_client__update_trace__happy_flow[None-None-None-None-019aee6c-c2c6-7884-beee-d927ba6b9d71]
tests.e2e.test_tracing ‑ test_opik_client__update_trace__happy_flow[None-None-None-None-019aee6c-f3dc-7b9d-9b40-f08f916ebb4f]

♻️ This comment has been updated with latest results.

@github-actions github-actions bot added python Pull requests that update Python code Python SDK labels Dec 5, 2025
- Added comprehensive unit tests for `detect_mime_type` and `get_file_extension` functions.
- Enhanced MIME type handling with improved comments for edge cases.
- Updated `decoder_helpers.py` to include clarified comments for better readability.
@github-actions github-actions bot added the tests Including test files, or tests related like configuration. label Dec 5, 2025
…tests

- Updated `AttachmentDecoder` to enforce stricter type handling for `raw_data`.
- Refactored filename generation with new utility: `create_attachment_filename` in `decoder_helpers`.
- Added extensive unit tests for `Base64AttachmentDecoder` covering multiple file types and edge cases.
- Replaced in-test constants with centralized test data for better reusability.
- Refined MIME type detection tests to use shared constants, improving maintainability.
- Introduced `AttachmentWithContext` dataclass to manage attachment metadata.
- Implemented `AttachmentsExtractor` for extracting and replacing encoded attachments within data structures.
- Included base64 pattern matching and decoding logic for attachment handling.
- Added support for context-specific attachment processing with entity type and ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Python SDK python Pull requests that update Python code tests Including test files, or tests related like configuration. work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants