fix: Add fallback to bundled images for profile pictures#10758
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe PR modifies two profile picture endpoints in the files API to implement fallback logic: both Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (4 passed)
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 |
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (40.04%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10758 +/- ##
==========================================
+ Coverage 32.39% 32.40% +0.01%
==========================================
Files 1368 1368
Lines 63414 63432 +18
Branches 9373 9374 +1
==========================================
+ Hits 20542 20555 +13
- Misses 41839 41844 +5
Partials 1033 1033
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/backend/base/langflow/api/v1/files.py (1)
173-195: Extract bundled profile pictures path resolution to shared helper to reduce duplicationThe code correctly implements the fallback logic described in the docstring. However, two functions in this file (
download_profile_pictureat line 150 andlist_profile_picturesat line 191) repeat the identical pattern:from langflow.initial_setup import setup package_path = Path(setup.__file__).parent / "profile_pictures"Extract this to a module-level helper function
_get_bundled_profile_pictures_base()to eliminate duplication and improve maintainability. This also gives a single point of change if bundled path resolution logic needs updating.Additionally, note that the current fallback is all-or-nothing: if users provide custom People images but no Space images, bundled Space images won't be shown. If per-folder fallback is desired instead, you'd need to check each subdirectory independently.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/backend/base/langflow/api/v1/files.py(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/backend/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
src/backend/**/*.py: Use FastAPI async patterns withawaitfor async operations in component execution methods
Useasyncio.create_task()for background tasks and implement proper cleanup with try/except forasyncio.CancelledError
Usequeue.put_nowait()for non-blocking queue operations andasyncio.wait_for()with timeouts for controlled get operations
Files:
src/backend/base/langflow/api/v1/files.py
src/backend/base/langflow/api/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Backend API endpoints should be organized by version (v1/, v2/) under
src/backend/base/langflow/api/with specific modules for features (chat.py, flows.py, users.py, etc.)
Files:
src/backend/base/langflow/api/v1/files.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 8/9
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 9/9
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 4/9
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 5/9
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 6/9
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 7/9
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 3/9
- GitHub Check: Run Frontend Tests / Playwright Tests - Shard 2/9
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Lint Backend / Run Mypy (3.11)
- GitHub Check: Test Docker Images / Test docker images
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
- GitHub Check: Update Component Index
- GitHub Check: Optimize new Python code in this PR
…gflow into cz/fix-profile-pic-error
This pull request updates the logic for retrieving and listing profile pictures to improve reliability and allow fallback to package-bundled images if custom images are missing. The main changes ensure that profile pictures are first searched for in the user’s config directory, and if not found, the system falls back to using default images bundled with the package.
Profile picture retrieval improvements:
download_profile_pictureinsrc/backend/base/langflow/api/v1/files.pyto first look for profile pictures in the user's config directory, and if not found, fallback to the package's bundledprofile_picturesdirectory.download_profile_pictureto only raise a 404 if neither location contains the requested image.Profile picture listing improvements:
list_profile_picturesinsrc/backend/base/langflow/api/v1/files.pyto first list images from the config directory, and if none are found, fallback to listing images from the package's bundled directory. [1] [2]Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.