Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory component fails to open folders starting with '\n' #3997

Closed
ChrisBriend-Relic opened this issue Oct 3, 2024 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@ChrisBriend-Relic
Copy link

Bug Description

When using the Directory component to load files, if my folder starts with the letter n, the '\n' sequence won't be escaped properly, resulting in the folder not being considered valid.

The error seems to be raised from langflow\base\data\utils.py:56 in retrieve_file_paths

Reproduction

  1. Use the Directory Component with c:\test\new_folder as the target folder
  2. get the following error:
    Error building Component Directory:
    Path c:\test
    ew_folder must exist and be a directory.

Expected behavior

Paths containing a folder with any alphanumerical combination should be supported

Who can help?

@ogabrie

Operating System

Win11

Langflow Version

1.0.18

Python Version

3.12

Screenshot

image

Flow File

No response

@ChrisBriend-Relic ChrisBriend-Relic added the bug Something isn't working label Oct 3, 2024
Copy link

dosubot bot commented Oct 3, 2024

Hey @ChrisBriend-Relic! 👋 I'm here to help you with any bugs, questions, or contributions you have. Let's squash those bugs together!

The issue you're encountering seems to be related to how escape sequences are handled in directory paths. In Python, the backslash (\) is used as an escape character, which can lead to unintended behavior when it's followed by certain characters, like n, which is interpreted as a newline character (\n).

To address this, you can use raw strings in Python by prefixing the string with r, which tells Python to treat backslashes as literal characters. For example, you can specify your path as r"c:\test\new_folder" to avoid the escape sequence issue.

If you're using the Directory component in Langflow and specifying paths directly, ensure that the paths are correctly formatted to prevent escape sequence interpretation. If the issue persists, it might require a code update in Langflow to handle such cases more gracefully.

To continue talking to Dosu, mention @dosu.

@ChrisBriend-Relic
Copy link
Author

Using string literals doesn't work, as the input is not python but the web UI for the component.
prefixing with 'r' and using quotes will result in the component trying to use the provided string as a relative path and it will still fail.

@Cristhianzl
Copy link
Member

hi @ChrisBriend-Relic hope you are doing well!

Follow up this PR: #4101 with the fix!
I will scape the code so the python lib can understand the path.
You was right about your thoughts!

Thanks!!

@ChrisBriend-Relic
Copy link
Author

Thanks! Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants