fix: Load flows autologin false#9578
Conversation
* docs: update support documentation to reflect rebranding to IBM Elite Support for Langflow * remove-info-tab * Apply suggestions from code review Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> --------- Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com>
|
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 WalkthroughRemoves AUTO_LOGIN gating from flow and bundle loading, switches superuser retrieval to role-based lookup, updates error handling, ensures a default folder for the superuser, adjusts JSON path filtering, and moves user import locally within functions in src/backend/base/langflow/initial_setup/setup.py. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as App Startup
participant Setup as setup.load_flows_from_directory
participant DB as DB (SQLModel)
participant FS as Filesystem
participant Loader as Flow Loader
App->>Setup: Invoke with session, dir_name
Setup->>DB: select(User).where(is_superuser==True)
alt Superuser found
Setup->>DB: get_or_create_default_folder(user.id)
Setup->>FS: Enumerate dir_name/flows/*.json
Setup->>Loader: Load each JSON flow
Loader-->>Setup: Success/Errors per file
Setup-->>App: Completed
else No superuser
Setup-->>App: Raise NoResultFound("No superuser found in the database")
end
sequenceDiagram
autonumber
participant App as App Startup
participant Setup as setup.load_bundles_from_urls
participant DB as DB (SQLModel)
participant Net as Network
participant Bundle as Bundle Processor
App->>Setup: Invoke with session, bundle_urls
Setup->>DB: select(User).where(is_superuser==True)
alt Superuser found
loop For each URL
Setup->>Net: Fetch bundle
Net-->>Setup: Bundle data
Setup->>Bundle: Process bundle for user
Bundle-->>Setup: Result
end
Setup-->>App: Completed
else No superuser
Setup-->>App: Raise NoResultFound("No superuser found in the database")
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
✨ Finishing touches🧪 Generate unit tests
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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/backend/base/langflow/initial_setup/setup.py (2)
861-864: Fix: assigning FolderRead object to folder_id field (should be UUID).get_or_create_default_folder returns FolderRead; existing.folder_id expects an ID. This currently sets a model into a UUID column and will break persistence.
- if existing.folder_id is None: - folder_id = await get_or_create_default_folder(session, user_id) - existing.folder_id = folder_id + if existing.folder_id is None: + folder = await get_or_create_default_folder(session, user_id) + existing.folder_id = folder.id
749-756: Bug: to_thread on iterdir returns a generator, not the entries (still blocks the event loop).Wrap the listing in list(...) inside the thread to avoid blocking I/O on the event loop.
- for file_path in await asyncio.to_thread(Path(flows_path).iterdir): + files = await asyncio.to_thread(lambda: list(Path(flows_path).iterdir())) + for file_path in files:
🧹 Nitpick comments (3)
src/backend/base/langflow/initial_setup/setup.py (3)
798-804: DRY: factor superuser lookup into a helper.The same query appears twice. Consider a small helper to centralize behavior and logging.
Add near this module (outside functions):
async def _get_superuser(session: AsyncSession): from langflow.services.database.models.user.model import User result = await session.exec(select(User).where(User.is_superuser == True)) # noqa: E712 return result.first()Then replace the duplicated blocks with:
user = await _get_superuser(session)Also applies to: 736-741
1032-1034: Docstring mismatch: function returns FolderRead, not UUID.Align the docstring with the actual return type and annotation.
- Returns: - UUID: The ID of the default folder. + Returns: + FolderRead: The default folder object for the user.
789-833: Optional: avoid repeated extraction path accumulation issues.When adding component paths, ensure you normalize and dedupe after extraction. Minor, but keeps paths tidy.
- component_paths.add(str(Path(temp_dir.name) / f"{dir_name}components")) + component_paths.add(str((Path(temp_dir.name) / f"{dir_name}components").resolve()))
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/backend/base/langflow/initial_setup/setup.py(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/base/langflow/initial_setup/setup.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). (1)
- GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (2)
src/backend/base/langflow/initial_setup/setup.py (2)
725-733: Confirm intended lifecycle: superuser creation vs. flow/bundle loading order.With AUTO_LOGIN no longer gating flow/bundle import, if AUTO_LOGIN is false and no superuser exists, imports will be skipped (as suggested above). Verify that this matches product expectations for fresh installs.
Would you like me to open a follow-up to optionally auto-create a disabled superuser (or defer imports until one exists) controlled by a setting?
Also applies to: 1004-1019
822-822: No compatibility issue with Path.is_relative_to usage
The project’s pyproject.toml specifiesrequires-python = ">=3.10,<3.14", so usingPath.is_relative_to(introduced in 3.9) is safe and no changes are needed.
| flows_path = settings_service.settings.load_flows_path | ||
| if not flows_path: | ||
| return | ||
| if not settings_service.auth_settings.AUTO_LOGIN: | ||
| await logger.awarning("AUTO_LOGIN is disabled, not loading flows from directory") | ||
| return | ||
|
|
||
| async with session_scope() as session: |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Guard: check flows_path exists before iterating.
Path.iterdir will raise if the directory is missing. Return early with a warning.
flows_path = settings_service.settings.load_flows_path
if not flows_path:
return
+ flows_dir = anyio.Path(flows_path)
+ if not await flows_dir.exists():
+ await logger.awarning(f"Flows path does not exist: {flows_path}")
+ returnCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/backend/base/langflow/initial_setup/setup.py around lines 731 to 735,
guard against a missing flows_path before calling Path.iterdir by ensuring
flows_path is valid and exists; if flows_path may be a string, convert it to a
pathlib.Path, check .exists() (and optionally .is_dir()), log a warning
indicating the configured flows path was not found, and return early instead of
attempting to iterate the directory.
| if user is None: | ||
| msg = "Superuser not found in the database" | ||
| msg = "No superuser found in the database" | ||
| raise NoResultFound(msg) | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Startup resilience: don’t crash if no superuser exists.
Raising here aborts startup in environments without a pre-created superuser (now that AUTO_LOGIN gating is removed). Prefer logging and skipping the import.
- if user is None:
- msg = "No superuser found in the database"
- raise NoResultFound(msg)
+ if user is None:
+ await logger.awarning("No superuser found; skipping flows import.")
+ returnCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/backend/base/langflow/initial_setup/setup.py around lines 742 to 745, the
code raises NoResultFound when no superuser exists which aborts startup; change
this to log a warning and skip the import instead of raising. Replace the raise
with a non-fatal path: log a clear message (use the module logger or Python
logging) indicating "No superuser found, skipping import" and then return or
otherwise skip the subsequent import logic so startup continues; add an import
for logging or use the existing logger if necessary.
| # Find superuser by role instead of username to avoid issues with credential reset | ||
| from langflow.services.database.models.user.model import User | ||
|
|
||
| stmt = select(User).where(User.is_superuser == True) # noqa: E712 | ||
| result = await session.exec(stmt) | ||
| user = result.first() | ||
| if user is None: | ||
| msg = "Superuser not found in the database" | ||
| msg = "No superuser found in the database" | ||
| raise NoResultFound(msg) |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Same resilience for bundles: skip gracefully if no superuser.
Mirror the behavior in load_flows_from_directory to avoid aborting startup.
- if user is None:
- msg = "No superuser found in the database"
- raise NoResultFound(msg)
+ if user is None:
+ await logger.awarning("No superuser found; skipping bundles import.")
+ return [], []📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Find superuser by role instead of username to avoid issues with credential reset | |
| from langflow.services.database.models.user.model import User | |
| stmt = select(User).where(User.is_superuser == True) # noqa: E712 | |
| result = await session.exec(stmt) | |
| user = result.first() | |
| if user is None: | |
| msg = "Superuser not found in the database" | |
| msg = "No superuser found in the database" | |
| raise NoResultFound(msg) | |
| # Find superuser by role instead of username to avoid issues with credential reset | |
| from langflow.services.database.models.user.model import User | |
| stmt = select(User).where(User.is_superuser == True) # noqa: E712 | |
| result = await session.exec(stmt) | |
| user = result.first() | |
| if user is None: | |
| await logger.awarning("No superuser found; skipping bundles import.") | |
| return [], [] |
🤖 Prompt for AI Agents
In src/backend/base/langflow/initial_setup/setup.py around lines 798 to 806, the
code currently raises NoResultFound if no superuser exists which aborts startup;
instead mirror load_flows_from_directory behavior by skipping gracefully:
replace the raise with a safe no-op path that logs or warns (use existing
logger) and returns/continues without error so startup proceeds, ensuring any
subsequent bundle-related logic checks for user being None before using it.
|
* docs: update support documentation to reflect support rebranding (#9538) * docs: update support documentation to reflect rebranding to IBM Elite Support for Langflow * remove-info-tab * Apply suggestions from code review Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> --------- Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> * setup.py disable autologin check for loading flows * [autofix.ci] apply automated fixes * New base branch, updated files for release --------- Co-authored-by: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
* fix: Load flows autologin false (#9578) * docs: update support documentation to reflect support rebranding (#9538) * docs: update support documentation to reflect rebranding to IBM Elite Support for Langflow * remove-info-tab * Apply suggestions from code review Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> --------- Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> * setup.py disable autologin check for loading flows * [autofix.ci] apply automated fixes * New base branch, updated files for release --------- Co-authored-by: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com> * fix: Move docling dependency into core dependencies instead of dev (#9906) * fix: Make sure strings can be parsed in the python interpreter (#9908) * fix: Execution of python interpreter * Update test_python_repl_tool.py * [autofix.ci] apply automated fixes --------- Co-authored-by: Carlos Coelho <80289056+carlosrcoelho@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * Remove docling dep from optional group since its in main dep group * fix: Correct the docling dependencies and Chroma in particular (#9925) fix: Correct docling dependencies --------- Co-authored-by: Sebastián Estévez <estevezsebastian@gmail.com> Co-authored-by: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Carlos Coelho <80289056+carlosrcoelho@users.noreply.github.com>



This pull request refactors the flow and bundle loading logic during startup to improve reliability and remove unnecessary dependencies on the
AUTO_LOGINsetting. The main change is to always attempt to load flows and bundles for the superuser, regardless of theAUTO_LOGINconfiguration, and to identify the superuser by role rather than username. This helps avoid issues when credentials are reset and ensures flows are loaded as expected.Authentication and user lookup improvements:
is_superuserrole instead of relying on the username, making the process more robust against credential changes (src/backend/base/langflow/initial_setup/setup.py) [1] [2].Removal of unnecessary
AUTO_LOGINchecks:AUTO_LOGINbefore loading flows and bundles, so these operations now run independently of the authentication setting (src/backend/base/langflow/initial_setup/setup.py) [1] [2] [3].Summary by CodeRabbit
New Features
Bug Fixes