{"record":{"id":"bd301b2f718cdb89","repo":"dotnet/orleans","slug":"missing-value-for-name","errorCode":null,"errorMessage":"Missing value for {name}.","messagePattern":"Missing value for (.+?)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"samples/JournalingAzureBlobJson/JournalingAzureBlobJson/Program.cs","lineNumber":220,"sourceCode":"                ?? DefaultBlobName;\n\n            var resetBlob = !args.Contains(\"--no-reset\", StringComparer.OrdinalIgnoreCase);\n\n            return new(connectionString, containerName, blobName, resetBlob);\n        }\n\n        private static string? GetOptionValue(string[] args, string name)\n        {\n            for (var i = 0; i < args.Length; i++)\n            {\n                if (!string.Equals(args[i], name, StringComparison.OrdinalIgnoreCase))\n                {\n                    continue;\n                }\n\n                if (i + 1 == args.Length)\n                {\n                    throw new ArgumentException($\"Missing value for {name}.\");\n                }\n\n                return args[i + 1];\n            }\n\n            return null;\n        }\n    }\n}\n\npublic interface IJournaledSampleGrain : IGrainWithStringKey\n{\n    Task<JournaledSampleSummary> RunScenario();\n    Task<JournaledSampleSummary> GetSummary();\n    Task Deactivate();\n}\n\npublic sealed class JournaledSampleGrain(","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/samples/JournalingAzureBlobJson/JournalingAzureBlobJson/Program.cs#L202-L238","documentation":"Thrown by the sample's command-line parser GetOptionValue when a flag like --connection-string, --container, or --blob is the very last token on the command line, so there is no following token to use as its value. It is a hard input-validation failure in the Program.Main path that builds the run configuration.","triggerScenarios":"Invoking the sample as `dotnet run -- --connection-string` (or --container / --blob) with nothing after the flag. The loop finds the flag at index i, then i + 1 == args.Length is true, so it throws ArgumentException instead of returning null.","commonSituations":"Copy-pasting a command and truncating it; quoting a value that the shell then drops; moving the flag to the end of the line and forgetting its argument; passing a value that starts with -- which is technically accepted but often a mistake.","solutions":["Supply the missing argument immediately after the flag, e.g. `dotnet run -- --connection-string \"<Azure storage conn string>\"`.","If you intended the flag to be optional, remove it entirely so the sample falls back to the AZURE_STORAGE_CONNECTION_STRING environment variable / default blob name.","Check your shell quoting: a value containing spaces must be quoted so it does not get split into separate args."],"exampleFix":"// before\nGetOptionValue(args, \"--connection-string\") // throws if --connection-string is last token\n\n// after: always pair the flag with its value on the command line\ndotnet run -- --connection-string \"DefaultEndpointsProtocol=...\" --container journaling","handlingStrategy":"validation","validationCode":"// Validate flag/value pairing before delegating to GetOptionValue\nfor (var i = 0; i < args.Length - 1; i++)\n    if (args[i].StartsWith(\"--\") && args[i + 1].StartsWith(\"--\"))\n        Console.WriteLine($\"Warning: flag {args[i]} may be missing its value.\");","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always quote values containing spaces so the shell does not split them.","Keep flags adjacent to their values on the command line.","For optional flags, omit them entirely rather than leaving them dangling."],"tags":["cli","args","configuration","validation","sample"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}