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

AddPythonApp crashes because it does not double quote paths with spaces in arguments list #6841

Closed
1 task done
DiAifU opened this issue Nov 28, 2024 · 4 comments
Closed
1 task done
Assignees
Labels
area-integrations Issues pertaining to Aspire Integrations packages blocked
Milestone

Comments

@DiAifU
Copy link

DiAifU commented Nov 28, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

AddPythonApp does not double quote paths it passes as arguments, especially the Python executable in venv when passed to the OpenTelemetry instrumentation executable.
Example :
Image

This results in the python script not starting because the argument list is not parsed correctly when there are spaces in the full path.
Image

Expected Behavior

The path should double quoted within the argument list to avoid this issue.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

SDK .NET :
Version: 9.0.100
Commit: 59db016f11
Workload version: 9.0.100-manifests.3068a692
MSBuild version: 17.12.7+5b8665660

Anything else?

Aspire 9.0.0 and Aspire.Hosting.Python 9.0.0

@joperezr joperezr added the untriaged New issue has not been triaged label Dec 9, 2024
@joperezr joperezr added the area-integrations Issues pertaining to Aspire Integrations packages label Jan 7, 2025
@eerhardt eerhardt added this to the 9.1 milestone Jan 15, 2025
@eerhardt eerhardt removed the untriaged New issue has not been triaged label Jan 15, 2025
@eerhardt
Copy link
Member

Seems like this should be an easy fix.

@eerhardt eerhardt self-assigned this Jan 15, 2025
@eerhardt
Copy link
Member

eerhardt commented Feb 4, 2025

I tried to simply double quote the path in 626f743.

However, things aren't working when I do that. The app fails to run:

 Traceback (most recent call last):
   File "<frozen runpy>", line 198, in _run_module_as_main
   File "<frozen runpy>", line 88, in _run_code
   File "D:\My Temp\AspireWithPython\InstrumentedPythonProject\.venv\Scripts\opentelemetry-instrument.exe\__main__.py", line 7, in <module>
     sys.exit(run())
              ~~~^^
   File "D:\git\aspire-samples\samples\AspireWithPython\InstrumentedPythonProject\.venv\Lib\site-packages\opentelemetry\instrumentation\auto_instrumentation\__init__.py", line 112, in run
     execl(executable, executable, *args.command_args)
     ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "<frozen os>", line 579, in execl
 TypeError: execv: path should be string, bytes or os.PathLike, not NoneType

@eerhardt
Copy link
Member

eerhardt commented Feb 4, 2025

Trying to do this outside of Aspire results in the same behavior as originally noted in the top post:

D:\My Temp\AspireWithPython\InstrumentedPythonProject>.venv\Scripts\opentelemetry-instrument.exe --traces_exporter otlp --logs_exporter console,otlp --metrics_exporter otlp "D:\My Temp\AspireWithPython\InstrumentedPythonProject\.venv\Scripts\python.exe" app.py

D:\My: can't open file 'D:\\My Temp\\AspireWithPython\\InstrumentedPythonProject\\Temp\\AspireWithPython\\InstrumentedPythonProject\\.venv\\Scripts\\python.exe': [Errno 2] No such file or directory

I believe this is an argument parsing issue in opentelemetry-instrument.exe.

I've opened Executing opentelemetry-instrument.exe on an app with a path with space doesn't work (open-telemetry/opentelemetry-python-contrib#3238) for this.

@eerhardt eerhardt modified the milestones: 9.1, Backlog Feb 4, 2025
@eerhardt
Copy link
Member

eerhardt commented Feb 4, 2025

I did more digging, and it looks like we shouldn't double quote paths at all. This is handled for us via DCP. We keep each argument separate in a string[] in the ExecutableSpec:

/// <summary>
/// Launch arguments to be passed to the Executable
/// </summary>
[JsonPropertyName("args")]
public List<string>? Args { get; set; }

DCP takes these separate args and will combine them correctly if an individual arg contains a space or tab.

So I'm closing this issue as .NET Aspire code is doing the correct thing. The underlying issue is in opentelemetry-instrument.exe - open-telemetry/opentelemetry-python-contrib#3238.

@eerhardt eerhardt closed this as completed Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages blocked
Projects
None yet
Development

No branches or pull requests

3 participants