{"record":{"id":"5f3522948dc7a42f","repo":"dotnet/yarp","slug":"unexpected-arg-remainder-1","errorCode":null,"errorMessage":"Unexpected arg '{remainder[1]}'.","messagePattern":"Unexpected arg '(.+?)'\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"testassets/TestClient/CommandLineArgs.cs","lineNumber":62,"sourceCode":"        }\n\n        if (i < args.Length)\n        {\n            return ParseRemainder(result, args.AsSpan().Slice(i));\n        }\n\n        return result;\n\n        static CommandLineArgs ParseRemainder(CommandLineArgs result, Span<string> remainder)\n        {\n            if (remainder.Length == 0)\n            {\n                throw new ArgumentException(\"Expected additional args.\");\n            }\n\n            if (remainder.Length > 1)\n            {\n                throw new ArgumentException($\"Unexpected arg '{remainder[1]}'.\");\n            }\n\n            result.Scenario = remainder[0];\n            return result;\n        }\n    }\n\n    public static void ShowHelp()\n    {\n        Console.WriteLine(\"ReverseProxy SampleClient.\\n\");\n        Console.WriteLine(\"--scenario <name>, -s <name>: Runs only the specified scenario.\");\n        Console.WriteLine(\n            \"--target <uri>, -t <uri>: Sets the target uri. By default, 'https://localhost:1443/' is used.\");\n        Console.WriteLine(\"--help, -h, -?, /?: Shows this help information.\");\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":79,"githubUrl":"https://github.com/dotnet/yarp/blob/bd11867bee7df522e7fd3effb08a9c85fd616908/testassets/TestClient/CommandLineArgs.cs#L44-L79","documentation":"Thrown by CommandLineArgs.ParseRemainder when the trailing positional arguments contain more than one token. The parser only expects a single positional value (the scenario name); any extra positional token is rejected with the offending value interpolated.","triggerScenarios":"Running the SampleClient with two or more positional arguments, e.g. `TestClient ScenarioA ScenarioB`, or mixing an unrecognized flag that falls through the switch and becomes positional.","commonSituations":"Typing two scenario names; passing an unquoted argument containing a space that splits into two tokens; an unrecognized --flag that the switch does not consume so it rolls into the remainder.","solutions":["Pass exactly one positional scenario name, or use --scenario/-s to name it explicitly.","Quote any argument containing spaces.","Remove unrecognized flags; only --scenario/-s, --target/-t, and --help/-h/-?//? are recognized."],"exampleFix":"// before\ndotnet TestClient ScenarioA ScenarioB\n\n// after\ndotnet TestClient --scenario ScenarioA","handlingStrategy":"validation","validationCode":"// Validate argv shape before parsing.\nvar positional = args.Where(a => !a.StartsWith('-')).ToList();\nif (positional.Count > 1)\n    throw new ArgumentException($\"Only one positional scenario argument is allowed; got {positional.Count}.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the scenario via --scenario/-s rather than positionally to avoid ambiguity.","Quote arguments that contain spaces.","Remember only --scenario, --target, and --help are recognized; unknown flags fall through to positional."],"tags":["cli","args","test-client","yarp"],"backgroundTag":null,"analyzedSha":"bd11867bee7df522e7fd3effb08a9c85fd616908","analyzedAt":"2026-08-13T21:29:49.359Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}