Skip to content

Conversation

@martiniifun
Copy link

When using rx.asset(path="logo.jpg", shared=True, subfolder="images"), the current implementation looks for .../logo.jpg instead of .../images/logo.jpg. This PR updates the logic to include the subfolder in the source file path check.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 21, 2025

Greptile Summary

This PR fixes a bug in the asset() function where the subfolder parameter was not being respected when looking up shared asset files. The source file path check now correctly includes the subfolder directory, ensuring files are found at the expected location (e.g., images/logo.jpg instead of just logo.jpg). The fix is minimal and consistent with how the destination path already handled the subfolder parameter. No issues found with the implementation.

Confidence Score: 5/5

  • This PR is safe to merge - it fixes a bug with minimal changes and no side effects.
  • The change is a one-line fix that correctly addresses the reported issue. The implementation is straightforward, uses standard Python Path operations, maintains backward compatibility when subfolder is None, and is consistent with how the destination path already handles the subfolder parameter. The fix is well-tested by the existing test suite in test_assets.py, which already validates this behavior with subfolders.
  • No files require special attention

Important Files Changed

Filename Overview
reflex/assets.py Fixed source file lookup for shared assets with subfolder. The change correctly includes the subfolder parameter when constructing the source file path, ensuring files are looked up in the correct directory when using subfolder parameter. Logic is consistent with destination path handling on line 82.

Sequence Diagram

sequenceDiagram
    participant User as User Code
    participant Asset as asset() function
    participant FS as File System
    participant Symlink as App Assets Dir
    
    User->>Asset: rx.asset(path="logo.jpg", shared=True, subfolder="images")
    Asset->>FS: Check source file at calling_file.parent/images/logo.jpg
    FS-->>Asset: File exists
    Asset->>Symlink: Create symlink at app/external/module/images/logo.jpg
    Symlink-->>Asset: Symlink created
    Asset-->>User: Return "/external/module/images/logo.jpg"
Loading

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 21, 2025

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

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

the subfolder arg is really intended as a target for where to copy the asset to in the final path.

the correct fix here would be to pass the the relative path for path argument, and then take just the filename part of the path when constructing the dst_file and return value.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants