Unclear error if executable has a long arguments
- 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
If you try to create an executable with a really long argument, you get a cryptic error about `metadata.annotations` being too long.
### Expected Behavior
It would be nice if this could be a bit more specific by telling you that this was because the Arguments were too long.
### Steps To Reproduce
Call `sqlcmd` with a long sql script as an argument
```cs
var query = new string(Enumerable.Repeat('a', 262144).ToArray());
var sql = builder.AddSqlServer("sql");
builder.AddExecutable("dbMigrator", "sqlcmd", packageDir)
.WithArgs(
"-S", serverExpresison,
"-U", "sa",
"-P", sql.Resource.PasswordParameter,
"-Q", query
)
```
### Exceptions (if any)
```
Failed to create resource dbMigrator
k8s.Autorest.HttpOperationException: Operation returned an invalid status code 'UnprocessableEntity', response body {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Executable.usvc-dev.developer.microsoft.com \"dbMigrator-uktkdybu\" is invalid: metadata.annotations: Too long: may not be more than 262144 bytes","reason":"Invalid","details":{"name":"dbMigrator-uktkdybu","group":"usvc-dev.developer.microsoft.com","kind":"Executable","causes":[{"reason":"FieldValueTooLong","message":"Too long: may not be more than 262144 bytes","field":"metadata.annotations"}]},"code":422}
at k8s.Kubernetes.SendRequestRaw(String requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken)
at k8s.AbstractKubernetes.ICustomObjectsOperations_CreateClusterCustomObjectWithHttpMessagesAsync[T](Object body, String group, String version, String plural, String dryRun, String fieldManager, String fieldValidation, Nullable`1 pretty, IReadOnlyDictionary`2 customHeaders, CancellationToken cancellationToken)
at k8s.AbstractKubernetes.k8s.ICustomObjectsOperations.CreateClusterCustomObjectWithHttpMessagesAsync(Object body, String group, String version, String plural, String dryRun, String fieldManager, String fieldValidation, Nullable`1 pretty, IReadOnlyDictionary`2 customHeaders, CancellationToken cancellationToken)
at Aspire.Hosting.Dcp.KubernetesService.<>c__DisplayClass17_0`1.<b__0>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 137
--- End of stack trace from previous location ---
at Aspire.Hosting.Dcp.KubernetesService.<>c__DisplayClass28_0`1.<b__0>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 478
--- End of stack trace from previous location ---
at Polly.ResiliencePipeline.<>c__10`1.<b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
at Polly.Outcome`1.GetResultOrRethrow()
at Polly.ResiliencePipeline.ExecuteAsync[TResult](Func`2 callback, CancellationToken cancellationToken)
at Aspire.Hosting.Dcp.KubernetesService.ExecuteWithRetry[TResult](DcpApiOperationType operationType, String resourceType, Func`2 operation, Func`2 isRetryable, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 475
at Aspire.Hosting.Dcp.DcpExecutor.CreateExecutableAsync(AppResource er, ILogger resourceLogger, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 1148
at Aspire.Hosting.Dcp.DcpExecutor.<>c__DisplayClass70_0.<g__CreateResourceExecutablesAsyncCore|0>d.MoveNext() in /_/src/Aspire.Hosting/Dcp/DcpExecutor.cs:line 1061
```
### .NET Version info
```
.NET SDK:
Version: 9.0.304
Commit: f12f5f689e
Workload version: 9.0.300-manifests.ad61bb1c
MSBuild version: 17.14.16+5d8159c5f
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.304\
.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.8
Architecture: x64
Commit: aae90fa090
.NET SDKs installed:
9.0.304 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
```
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.