You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
reflex export crashes with a traceback (and leaves a partial backend.zip) on a directory symlink pointing outside the app or a dangling symlink #7851
The backend zip is built by _zip() in reflex/utils/build.py. It walks the app directory with os.walk(root_directory, followlinks=True), resolves every directory (Path(directory_path).resolve()) and stores each file under file.relative_to(root_directory). Three common layouts break it:
A directory symlink that resolves outside the app (a shared common/ package linked into the app in a monorepo): relative_to raises ValueError: '/elsewhere/common/x.py' is not in the subpath of '/app'. reflex export prints a traceback and leaves a partial backend.zip.
A dangling symlink (to a deleted file): os.walk lists it as a file and zipf.write raises FileNotFoundError, same outcome.
A directory symlink inside the app (pointing to another directory of the same app): its files are written twice under two names (duplicate zip entries; the archive contains both copies).
reflex deploy catches the error and prints a one-line message without uploading, so the deploy is safe, but reflex export users get a raw traceback. File symlinks are archived by content and work. Not a regression; last verified on 0.10.1a1, and the code is unchanged on main.
Case 1: the linked directory's files are archived under the link's path inside the app (shared/mod.py), since followlinks=True says links are followed; or, if links outside the app are not wanted, they are skipped with one warning naming the link. Either way, no traceback.
Case 2: the dangling link is skipped with a warning.
Case 3: each file is archived once.
Fix direction
Code: _zip() in reflex/utils/build.py.
Compute archive names from the unresolved walk path (Path(directory_path) relative to the unresolved root) instead of resolving each directory, so a followed link keeps its in-app path; keep using resolved paths only for loop and duplicate detection (track (st_dev, st_ino) of visited directories to skip a directory reached twice, which also guards against symlink loops).
Skip and warn for entries that do not exist (Path.exists() is False for a dangling link).
Keep the existing exclusions (hidden entries, venvs, .db files, files_to_exclude) working on the unresolved paths.
Tests: unit tests in tests/units/utils/test_build.py (or the existing zip tests) for the three cases, using tmp_path and os.symlink (skip on Windows when symlinks are unavailable).
Activity
linear-code commentedon Nov 11, 2026
ENG-13999