Description
The convert_path_to_unix_path function in samcli/lib/utils/path_utils.py does not handle empty string input correctly. Passing an empty string returns "." instead of "".
Steps to reproduce
from samcli.lib.utils.path_utils import convert_path_to_unix_path
result = convert_path_to_unix_path("")
print(repr(result)) # prints '.' instead of ''
Expected behavior
An empty string input should return an empty string.
Actual behavior
PureWindowsPath("").as_posix() returns "." (the current directory), which is incorrect when the intent is to pass through an empty/unset path value.
Fix
Add an early return for empty input:
def convert_path_to_unix_path(path: str) -> str:
if not path:
return path
return PureWindowsPath(path).as_posix()
Description
The
convert_path_to_unix_pathfunction insamcli/lib/utils/path_utils.pydoes not handle empty string input correctly. Passing an empty string returns"."instead of"".Steps to reproduce
Expected behavior
An empty string input should return an empty string.
Actual behavior
PureWindowsPath("").as_posix()returns"."(the current directory), which is incorrect when the intent is to pass through an empty/unset path value.Fix
Add an early return for empty input: