{"record":{"id":"f4732338cac87b7e","repo":"dotnet/orleans","slug":"maxmetadataonlyconflictretries-must-be-non-negativ-f47323","errorCode":null,"errorMessage":"MaxMetadataOnlyConflictRetries must be non-negative.","messagePattern":"MaxMetadataOnlyConflictRetries must be non-negative\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorage.cs","lineNumber":1280,"sourceCode":"            ArgumentNullException.ThrowIfNull(tableClientProvider);\n\n            Logger = logger;\n            Options = options.Value;\n            ArgumentNullException.ThrowIfNull(Options);\n            AzureTableJournalStorageOptions.ValidateTableName(Options.TableName);\n            if (Options.CompactionRowCountThreshold <= 0)\n            {\n                throw new ArgumentOutOfRangeException(nameof(options), $\"{nameof(AzureTableJournalStorageOptions.CompactionRowCountThreshold)} must be positive.\");\n            }\n\n            if (Options.CompactionSizeThreshold <= 0)\n            {\n                throw new ArgumentOutOfRangeException(nameof(options), $\"{nameof(AzureTableJournalStorageOptions.CompactionSizeThreshold)} must be positive.\");\n            }\n\n            if (Options.MaxMetadataOnlyConflictRetries < 0)\n            {\n                throw new ArgumentOutOfRangeException(nameof(options), $\"{nameof(AzureTableJournalStorageOptions.MaxMetadataOnlyConflictRetries)} must be non-negative.\");\n            }\n\n            if (Options.MetadataOnlyConflictInitialBackoff < TimeSpan.Zero)\n            {\n                throw new ArgumentOutOfRangeException(nameof(options), $\"{nameof(AzureTableJournalStorageOptions.MetadataOnlyConflictInitialBackoff)} must be non-negative.\");\n            }\n\n            if (Options.MetadataOnlyConflictMaxBackoff < TimeSpan.Zero)\n            {\n                throw new ArgumentOutOfRangeException(nameof(options), $\"{nameof(AzureTableJournalStorageOptions.MetadataOnlyConflictMaxBackoff)} must be non-negative.\");\n            }\n\n            JournalFormatKey = journalFormatKey;\n            TableClientProvider = tableClientProvider;\n            Instruments = instruments;\n        }\n\n        public ILogger<AzureTableJournalStorage> Logger { get; }","sourceCodeStart":1262,"sourceCodeEnd":1298,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Journaling.AzureStorage/AzureTableJournalStorage.cs#L1262-L1298","documentation":"AzureTableJournalStorageOptions.MaxMetadataOnlyConflictRetries was set to a negative value. The constructor (AzureTableJournalStorage.cs:1278) requires it non-negative because it counts retry attempts after a metadata-only ETag conflict (zero means no in-place retry, falling back immediately to InconsistentStateException). The argument blamed is `options`.","triggerScenarios":"Configuring MaxMetadataOnlyConflictRetries < 0; thrown at AzureTableJournalStorage.cs:1280.","commonSituations":"A config sentinel like -1 meant to mean 'unlimited' but the option does not support that; misbound integer from appsettings; arithmetic that underflowed.","solutions":["Set MaxMetadataOnlyConflictRetries to a non-negative integer (default 5).","Use 0 to disable in-place metadata-conflict retries if immediate fallback is desired.","Validate via IValidateOptions<T> at startup."],"exampleFix":"// before\noptions.MaxMetadataOnlyConflictRetries = -1;\n\n// after\noptions.MaxMetadataOnlyConflictRetries = AzureTableJournalStorageOptions.DEFAULT_MAX_METADATA_ONLY_CONFLICT_RETRIES;","handlingStrategy":"validation","validationCode":"if (options.MaxMetadataOnlyConflictRetries < 0)\n    throw new ArgumentOutOfRangeException(nameof(options.MaxMetadataOnlyConflictRetries), \"Must be non-negative\");","typeGuard":"static bool IsValidMaxRetries(int v) => v >= 0;","tryCatchPattern":null,"preventionTips":["Use 0 to disable in-place retries instead of negative values.","Validate via IValidateOptions<T>.","Avoid sentinel magic numbers like -1."],"tags":["configuration","options","validation"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}