{"record":{"id":"851096cf7247e5c2","repo":"microsoft/aspire","slug":"command-line-args-must-be-strings","errorCode":null,"errorMessage":"Command line args must be strings","messagePattern":"Command line args must be strings","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Docker/DockerComposeServiceResource.cs","lineNumber":244,"sourceCode":"        }\n\n        if (env.Count > 0)\n        {\n            foreach (var variable in env)\n            {\n                composeService.AddEnvironmentalVariable(variable.Key, variable.Value);\n            }\n        }\n\n        var args = new List<string>();\n\n        foreach (var arg in Args)\n        {\n            var value = await this.ProcessValueAsync(arg).ConfigureAwait(false);\n\n            if (value is not string str)\n            {\n                throw new NotSupportedException(\"Command line args must be strings\");\n            }\n\n            args.Add(str);\n        }\n\n        if (args.Count > 0)\n        {\n            if (IsShellExec)\n            {\n                var sb = new StringBuilder();\n                foreach (var command in args)\n                {\n                    // Escape any environment variables expressions in the command\n                    // to prevent them from being interpreted by the docker compose CLI\n                    EnvVarEscaper.EscapeUnescapedEnvVars(command, sb);\n                    composeService.Command.Add(sb.ToString());\n                    sb.Clear();\n                }","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Docker/DockerComposeServiceResource.cs#L226-L262","documentation":"Type guard in AddEnvironmentVariablesAndCommandLineArgsAsync: while materializing the service's Args, one argument value resolved by ProcessValueAsync to a non-string object (e.g. an int, bool, or resource reference result). The compose file serializer only accepts string command-line tokens, so the resolved value's runtime type is rejected.","triggerScenarios":"Thrown at src/Aspire.Hosting.Docker/DockerComposeServiceResource.cs:244 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the argument in an expression that converts it to string, e.g. \"{arg.Value}\" formatting, so ProcessValueAsync yields a string","Avoid passing raw numeric/boolean literal values directly in Args for compose targets","Check for unresolved resource references (connection strings, endpoints) being passed as args and project them to strings first"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}