fix: persist interaction image encodings#237
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe SQLite interactions schema, persistence paths, and message construction now preserve ChangesImage encoding persistence and prompt flow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/server/services/profile/test_profile_generation_service_utils.py`:
- Around line 156-158: The profile generation test is hardcoding a JPEG data URL
for a PNG fixture, so update the test data to match the actual image type or
make the MIME type flow through the implementation. In
test_profile_generation_service_utils, use the real type derived from the
fixture in the assertions around image data URLs, and check the corresponding
storage/prompt construction in the profile generation path so it preserves the
MIME type instead of assuming image/jpeg.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1f00f1a1-db10-4094-9414-072702703d5c
📒 Files selected for processing (4)
reflexio/server/services/storage/sqlite_storage/_base.pyreflexio/server/services/storage/sqlite_storage/_profiles.pytests/server/services/profile/test_profile_generation_service_utils.pytests/server/services/storage/test_storage_contract_profiles.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@reflexio/server/services/service_utils.py`:
- Around line 62-76: The helper _image_data_url_from_encoding is defaulting
unknown payloads to data:image/jpeg, which relabels non-JPEG images and breaks
round-trips. Update this path so unknown headers are not rewritten as JPEG:
either return an error/raise for unsupported image signatures, or change the
flow to carry the original MIME type through InteractionData.image_encoding and
use it here. Keep the existing sniffing logic in _image_mime_type_from_bytes,
but remove the unconditional JPEG fallback in _image_data_url_from_encoding.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0a8a7658-e801-4ade-8c9b-462ece2a5ebf
📒 Files selected for processing (3)
reflexio/server/services/service_utils.pytests/server/services/profile/test_profile_generation_service_utils.pytests/server/services/test_service_utils_extended.py
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/server/services/profile/test_profile_generation_service_utils.py
Summary
image_encodingcolumn during schema migration.Changes
Interaction.image_encodingalongside existing interaction media fields.image_encoding TEXT NOT NULL DEFAULT ''.image_urlblocks in profile extraction prompts.Test Plan
uv run ruff check ...uv run pyright ...uv run pytest -o 'addopts=' tests/server/services/storage/test_storage_contract_profiles.py::TestInteractionCRUD::test_interaction_image_encoding_round_trips_through_extraction_reads tests/server/services/profile/test_profile_generation_service_utils.py::test_profile_extraction_prompt_keeps_image_encoding_after_storage_round_trip -qSummary by CodeRabbit
image_encodingon interactions, including persistence and return across storage and profile-extraction flows.data:<mime>;base64,...URLs (JPEG/PNG/GIF/WebP), not just JPEG.image_encodingfrom being dropped or changed during saves, schema migrations, and grouped/flat reads.image_encodingpreservation and correct MIME/data-URL construction, including rejection of unsupported signatures.