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
Providing a file path in form of pure to any ‘files’ (data_files, combined_files, attachment_files) parameter in import request, results in error: “ValueError: File paths in import are not unique.“
Request object is expecting a list of strings, but when just a single str is provided, it carries on iterating through the parameter treating each 'char' as a separate path.
Should we add a simple ‘if not list’ check and throw more meaningful error msg in such case?
📝 Steps to reproduce
prepare ExcelImportJobRequest where one of files parameter is a 'str' instead of ['str']`
and create a job with it
konradkudziagranta
changed the title
Confusing error message if files path parameter provided to ImportRequest is of <str> type
Confusing error message if list of file paths parameter provided to ImportRequest is of type <str>
Nov 14, 2024
I'd normally say that we shouldn't add this. The package is type hinted, which means a modern IDE will warn that you've done something wrong, and mypy will also throw an error if you provide a string when it expects a list. Also, the argument name is plural, which gives another very strong hint that some kind of container is expected.
This is a bit of a weird case in Python though, since strings and lists are both sequences, which can cause unexpected errors in cases like this. And since we don't actually try to resolve the file before raising the error, the error message is not obvious what's going on.
🔍 Before submitting the issue
🐞 Description of the bug
Providing a file path in form of pure to any ‘files’ (data_files, combined_files, attachment_files) parameter in import request, results in error:
“ValueError: File paths in import are not unique.“
Request object is expecting a list of strings, but when just a single str is provided, it carries on iterating through the parameter treating each 'char' as a separate path.
Should we add a simple ‘if not list’ check and throw more meaningful error msg in such case?
📝 Steps to reproduce
prepare ExcelImportJobRequest where one of files parameter is a 'str' instead of ['str']`
and create a job with it
💻 Which operating system are you using?
Windows
📀 Which ANSYS version are you using?
ansys-grantami-jobqueue 1.1.0rc0
ansys-grantami-serverapi-openapi 4.0.0
ansys-openapi-common 2.2.0
GRANTA_MIScriptingToolkit 4.1.75
MI b. 25.1.1888
🐍 Which Python version are you using?
3.13
📦 Installed packages
The text was updated successfully, but these errors were encountered: