Error on aspire publish when combining Kubernetes and NATS integrations
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
While building the apphost during execution of the publish command the NATS Hosting integration calls .WithArgs on the builder and passes a `ReferenceExpression` for the --user and --pass args:
https://github.com/dotnet/aspire/blob/5b92c02bcd205171118aa701ea905a073e61f24e/src/Aspire.Hosting.Nats/NatsBuilderExtensions.cs#L100
The Kubernetes Integration expects a string, which causes an exception while building:
https://github.com/dotnet/aspire/blob/5b92c02bcd205171118aa701ea905a073e61f24e/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs#L282
### Expected Behavior
AddNats after AddKubernetesEnvironment does not cause an exception
### Steps To Reproduce
```
#:sdk Aspire.AppHost.Sdk@13.0.2
#:package Aspire.Hosting.Nats@13.0.2
#:package Aspire.Hosting.Kubernetes@13.0.2-preview.1.25603.5
var builder = DistributedApplication.CreateBuilder(args);
builder.AddKubernetesEnvironment("k8s");
builder.AddNats("nats");
builder.Build().Run();
```
### Exceptions (if any)
```
Unhandled exception. System.AggregateException: One or more errors occurred. (Command line
args must be strings)
---> System.NotSupportedException: Command line args must be strings
at
Aspire.Hosting.Kubernetes.KubernetesResource.ProcessArgumentsAsync(KubernetesEnvironmentCon
text environmentContext, DistributedApplicationExecutionContext executionContext,
CancellationToken cancellationToken) in
/_/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs:line 285
```
### .NET Version info
.NET SDK:
Version: 10.0.100
Commit: b0f34d51fc
Workload version: 10.0.100-manifests.4c0ca8ba
MSBuild version: 18.0.2+b0f34d51f
### Anything else?
I assume the fix should be made on the Nats Hosting Integration side by converting the ReferenceExpression to a string.
Contributor guide
Research direction
Start with src/Aspire.Hosting.Nats/NatsBuilderExtensions.cs around line 100 and src/Aspire.Hosting.Kubernetes/KubernetesResource.cs around line 282. Reproduce the failure with AddKubernetesEnvironment followed by AddNats using the supplied sample, then verify that the publish/build path completes without the command-line-argument exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, kubernetes
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100