Closed exones closed 1 year ago
Thx for reporting, it should definitely be ignoring any non matching commands which should now be resolved from this commit: https://github.com/ServiceStack/ServiceStack/commit/1e3472662f4c473085b59aa27dfe6c31f7cc26a0
This change is available from v6.8.1+ that's now available on MyGet.
Note: purpose of --AppTasks
is to run AppTask commands which are designed to run the specified command in the context of an App then immediately exit before the Server starts.
Reproduce: Have a .NET 6.0 executable project with ServiceStack running inside ASP.NET (with using
.UseKestrel()
) and one service of any kind, smth similar to:And in Startup:
Run the executable with duplicated keys in the call, for example:
Expected ServiceStack doesn't try to intercept arguments, so nothing crashes when launching the application or accessing a service.
Observed Hard crash with call to
Environment.Exit()
fromAppTasks
class because ServiceStack assumes two things: the format of command line arges starting with--
or/
and separated with=
, and that there are no duplicate keys (call to.ToDictionary
).Offending line: https://github.com/ServiceStack/ServiceStack/blob/7e51d4a8080cd4818be00f9cfb5a44b83c44e6a3/ServiceStack/src/ServiceStack.Common/AppTasks.cs#L64
And much more suprisingly the fact that https://github.com/ServiceStack/ServiceStack/blob/7e51d4a8080cd4818be00f9cfb5a44b83c44e6a3/ServiceStack/src/ServiceStack.Common/AppTasks.cs#L124 kills the app although ServiceStack is an applicative library.
Proposition Allow duplicate arguments OR event better don't assume anything about the application's command line arguments format OR at least swallow exception and assume no
--AppTasks
arg is passed (https://github.com/ServiceStack/ServiceStack/blob/7e51d4a8080cd4818be00f9cfb5a44b83c44e6a3/ServiceStack/src/ServiceStack.Common/AppTasks.cs#L65). In my opinion, the way the application manages command line must never be responsibility of an applicative lib.Many application allow duplicate cmd args keys (example:
docker -v /vol1:/vol1 -v /vol2:vol2
).