Skip to content

Attaching files with spaces in the file name causes a ValueError when writing the AASX #236

@WelliSolutions

Description

@WelliSolutions

I was adding a file to an AASX which contained spaces. When writing the AASX, I got the following traceback:

Traceback (most recent call last):
[...]
  File "[...]\venv\Lib\site-packages\basyx\aas\adapter\aasx.py", line 415, in write_aas
    self.write_all_aas_objects("/aasx/data.{}".format("json" if write_json else "xml"),
  File "[...]\venv\Lib\site-packages\basyx\aas\adapter\aasx.py", line 552, in write_all_aas_objects
    with self.writer.open_part(file_name, content_type) as p:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[...]\venv\Lib\site-packages\pyecma376_2\package_model.py", line 366, in open_part
    check_part_name(name)
  File "[...]\venv\Lib\site-packages\pyecma376_2\package_model.py", line 658, in check_part_name
    raise ValueError("{} is not an URI path with multiple segments (each not empty and not starting with '.') "
ValueError: '/aasx/attachments/file with space.txt' is not an URI path with multiple segments (each not empty and not starting with '.') or not starting with '/' or ending wit '/'

Note that the error message is a bit misleading. It's not because of the / and not because of the .. I double checked and it's the space that causes the problem.

My expectation is that the Basyx library handles the file name at the level of DictSupplementaryFileContainer and the add_file() method. As written in the tutorial, the method shall return the actual file name. If spaces are not allowed, please return a file name without spaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsdkSomething to do with the `sdk` package

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions