{"record":{"id":"3bce721d702f9d94","repo":"dotnet/orleans","slug":"invalid-nameof-adonetstreamoptions-values-for-a-3bce72","errorCode":null,"errorMessage":"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionBatchSize)} must be greater than zero.","messagePattern":"Invalid (.+?) values for ADO\\.NET Streaming Provider '(.+?)': (.+?) must be greater than zero\\.","errorType":"validation","errorClass":"OrleansConfigurationException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamOptionsValidator.cs","lineNumber":50,"sourceCode":"\n        if (options.EvictionInterval < TimeSpan.Zero)\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionInterval)} must be greater than zero.\");\n        }\n\n        if (options.ExpiryTimeout < TimeSpan.Zero)\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.ExpiryTimeout)} must be greater than zero.\");\n        }\n\n        if (options.DeadLetterEvictionTimeout < TimeSpan.Zero)\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.DeadLetterEvictionTimeout)} must be greater than zero.\");\n        }\n\n        if (options.EvictionBatchSize < 0)\n        {\n            throw new OrleansConfigurationException($\"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionBatchSize)} must be greater than zero.\");\n        }\n    }\n}","sourceCodeStart":32,"sourceCodeEnd":53,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamOptionsValidator.cs#L32-L53","documentation":"Thrown by AdoNetStreamOptionsValidator.ValidateConfiguration when AdoNetStreamOptions.EvictionBatchSize is set to a negative value. EvictionBatchSize controls the maximum number of stream messages moved to dead-letters or deleted per eviction cycle. The guard rejects negatives so the eviction batch never inverts semantics. Note the check is '< 0', so zero is permitted (it effectively disables batch eviction), even though the message text says 'must be greater than zero'.","triggerScenarios":"Calling ValidateConfiguration() (run automatically by Orleans at silo/client startup) after configuring an ADO.NET streaming provider whose AdoNetStreamOptions.EvictionBatchSize was explicitly assigned a negative int. For example: options.EvictionBatchSize = -1; or reading a negative value from configuration.","commonSituations":"Misreading the option as a count that must be strictly positive and passing -1 to 'disable' it; binding EvictionBatchSize from an appsettings key that is missing (parsed as a sentinel) or mistyped; copying a TimeSpan-based negative value into this int field by mistake.","solutions":["Set EvictionBatchSize to a non-negative value (default is 1000); use 0 only if you intend to disable batch eviction.","Check your silo/client builder configuration where AddAdoNetStreams is called and correct or remove the EvictionBatchSize assignment.","Verify the appsettings/source feeding AdoNetStreamOptions does not supply a negative value."],"exampleFix":"// before\nsiloBuilder.AddAdoNetStreams(\"my-provider\", new AdoNetStreamOptions\n{\n    Invariant = \"MySql.Data.MySqlClient\",\n    ConnectionString = connectionString,\n    EvictionBatchSize = -1 // throws at startup\n});\n\n// after\nsiloBuilder.AddAdoNetStreams(\"my-provider\", new AdoNetStreamOptions\n{\n    Invariant = \"MySql.Data.MySqlClient\",\n    ConnectionString = connectionString,\n    EvictionBatchSize = 500\n});","handlingStrategy":"validation","validationCode":"// Validate before the silo starts up.\nif (options.EvictionBatchSize < 0)\n    throw new ArgumentOutOfRangeException(nameof(options.EvictionBatchSize), \"Must be non-negative.\");\n// Optionally clamp: options.EvictionBatchSize = Math.Max(0, options.EvictionBatchSize);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all AdoNetStreamOptions assignments in one place so values are auditable.","Bind numeric options from strongly-typed config sections rather than ad-hoc string parsing.","Rely on the built-in IConfigurationValidator (AdoNetStreamOptionsValidator) to surface misconfig at startup."],"tags":["adonet","streaming","configuration","validation","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}