Skip to content

fix: Add fallback to bundled images for profile pictures#10758

Merged
Cristhianzl merged 19 commits into
mainfrom
cz/fix-profile-pic-error
Dec 1, 2025
Merged

fix: Add fallback to bundled images for profile pictures#10758
Cristhianzl merged 19 commits into
mainfrom
cz/fix-profile-pic-error

Conversation

@Cristhianzl
Copy link
Copy Markdown
Member

@Cristhianzl Cristhianzl commented Nov 27, 2025

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:

  • Updated download_profile_picture in src/backend/base/langflow/api/v1/files.py to first look for profile pictures in the user's config directory, and if not found, fallback to the package's bundled profile_pictures directory.
  • Changed error handling in download_profile_picture to only raise a 404 if neither location contains the requested image.

Profile picture listing improvements:

  • Updated list_profile_pictures in src/backend/base/langflow/api/v1/files.py to first list images from the config directory, and if none are found, fallback to listing images from the package's bundled directory. [1] [2]
image

Summary by CodeRabbit

  • New Features

    • Enhanced profile picture handling with fallback logic: system now checks local configuration first, then falls back to bundled profile pictures if not found.
  • Documentation

    • Updated API endpoint documentation to reflect the new fallback behavior for profile picture retrieval.

✏️ Tip: You can customize this high-level summary in your review settings.

@Cristhianzl Cristhianzl self-assigned this Nov 27, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 27, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The PR modifies two profile picture endpoints in the files API to implement fallback logic: both download_profile_picture and list_profile_pictures now check the local config directory first, then fall back to the package's bundled resources if files are not found locally. Docstrings and inline comments have been updated to document this behavior.

Changes

Cohort / File(s) Summary
Profile pictures endpoints
src/backend/base/langflow/api/v1/files.py
Modified download_profile_picture to check config_dir/profile_pictures/folder_name/file_name first, then fall back to bundled package resources; updated list_profile_pictures to list files from config_dir/profile_pictures directories first, then fall back to bundled resources if empty. Updated docstrings and added clarifying inline comments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify fallback logic paths are correct for both local and bundled resources
  • Ensure docstrings accurately reflect the new behavior
  • Confirm 404 handling is appropriate when neither local nor bundled resources exist

Possibly related PRs

Suggested labels

fix, bug

Suggested reviewers

  • mfortman11
  • lucaseduoli

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error PR adds fallback logic to profile picture endpoints but lacks corresponding test coverage for the new functionality. Add test file covering both download_profile_picture and list_profile_pictures with fallback scenarios, 404 cases, and security validation.
Test Quality And Coverage ⚠️ Warning Pull request modifies profile picture endpoints but lacks corresponding test coverage for fallback behavior, error cases, and security validations. Add pytest tests covering: (1) successful retrieval from config directory, (2) fallback to bundled images, (3) 404 responses when missing, (4) list endpoint responses, and (5) path traversal security.
Test File Naming And Structure ⚠️ Warning PR modifies download_profile_picture and list_profile_pictures endpoints but includes no test files following pytest patterns (test_*.py) for the backend changes. Add backend tests in tests/test_files.py covering: profile picture downloads from config directory, fallback to bundled assets, 404 handling, and path traversal protection verification.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: adding a fallback to bundled images for profile pictures when custom images are unavailable.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Excessive Mock Usage Warning ✅ Passed Test suite uses real fixtures and minimal mocking via monkeypatch, focusing on integration testing with actual file operations rather than excessive mocks.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the bug Something isn't working label Nov 27, 2025
@github-actions github-actions Bot removed the bug Something isn't working label Nov 27, 2025
@github-actions github-actions Bot added the bug Something isn't working label Nov 27, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 61.90476% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.40%. Comparing base (6d442ea) to head (9569ccf).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/lfx/src/lfx/base/data/base_file.py 11.11% 7 Missing and 1 partial ⚠️

❌ 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

Impacted file tree graph

@@            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              
Flag Coverage Δ
backend 51.29% <100.00%> (+0.03%) ⬆️
frontend 14.08% <ø> (ø)
lfx 40.04% <11.11%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/backend/base/langflow/api/v1/files.py 68.84% <100.00%> (+2.69%) ⬆️
src/lfx/src/lfx/base/data/base_file.py 35.45% <11.11%> (-0.65%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 duplication

The code correctly implements the fallback logic described in the docstring. However, two functions in this file (download_profile_picture at line 150 and list_profile_pictures at 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7524379 and 697d857.

📒 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 with await for async operations in component execution methods
Use asyncio.create_task() for background tasks and implement proper cleanup with try/except for asyncio.CancelledError
Use queue.put_nowait() for non-blocking queue operations and asyncio.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

Comment thread src/backend/base/langflow/api/v1/files.py
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 27, 2025

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 15%
15.24% (4188/27479) 8.46% (1778/20993) 9.57% (579/6049)

Unit Test Results

Tests Skipped Failures Errors Time
1638 0 💤 0 ❌ 0 🔥 21.265s ⏱️

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 27, 2025
@Cristhianzl Cristhianzl added the Release Label to be set only on release PR label Nov 28, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Dec 1, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Dec 1, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Dec 1, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Dec 1, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Dec 1, 2025
@Cristhianzl Cristhianzl enabled auto-merge December 1, 2025 14:45
@Cristhianzl Cristhianzl added this pull request to the merge queue Dec 1, 2025
@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Dec 1, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 1, 2025
@Cristhianzl Cristhianzl added this pull request to the merge queue Dec 1, 2025
Merged via the queue into main with commit 677f87f Dec 1, 2025
93 of 94 checks passed
@Cristhianzl Cristhianzl deleted the cz/fix-profile-pic-error branch December 1, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer Release Label to be set only on release PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants