python-bonobo / bonobo

Extract Transform Load for Python 3.5+
https://www.bonobo-project.org/
Apache License 2.0
1.59k stars 146 forks source link

CsvReader does not accept files in another directory #397

Open alaindebecker opened 3 years ago

alaindebecker commented 3 years ago

bonobo.CsvReader('../input.csv') gives an error. However the file exists and bonobo.CsvReader('input.csv') works fine when the same file is moved into the working directory.

The error comes from: fs.errors.IllegalBackReference path '../Employees.txt' contains back-references outside of filesystem which tends to indicate that the root of the fs is reset by bonobo.

Note that the log message tells the error is generated at line 56 of bonobo\nodes\io\base.py. While in github this script has only 46 lines.

 Traceback (most recent call last):
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\bonobo\execution\strategies\executor.py", line 54, in _runner
│     with node:
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\bonobo\execution\contexts\base.py", line 73, in __enter__
│     self.start()
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\bonobo\execution\contexts\node.py", line 85, in start
│     self._stack.setup(self)
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\bonobo\config\processors.py", line 124, in setup
│     _append_to_context = next(_processed)
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\bonobo\nodes\io\base.py", line 52, in file
│     with self.open(fs) as file:
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\bonobo\nodes\io\base.py", line 56, in open
│     return fs.open(self.path, self.mode, encoding=self.encoding)
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\fs\osfs.py", line 631, in open
│     _path = self.validatepath(path)
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\fs\osfs.py", line 678, in validatepath
│     return super(OSFS, self).validatepath(path)
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\fs\base.py", line 1502, in validatepath
│     path = abspath(normpath(path))
│   File "C:\Users\alain\AppData\Local\Programs\Python\Python39\lib\site-packages\fs\path.py", line 89, in normpath
│     raise IllegalBackReference(path)
╰ fs.errors.IllegalBackReference  path '../Employees.txt' contains back-references outside of filesystem
deepu9 commented 3 years ago

@alaindebecker Try the same solution as #398. I'm sure that'll fix both the issues.

alaindebecker commented 3 years ago

I know it's probably the same issue. When issue #398 will be solved, I'll try if the workaround works here.