{"record":{"id":"0dfd16d7dd0f6bb4","repo":"dotnetcore/CAP","slug":"specified-argument-was-out-of-the-range-of-valid-values-0dfd16","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'index')","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'index'\\)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/DotNetCore.CAP.Dashboard/CircularBuffer.cs","lineNumber":62,"sourceCode":"    public int Capacity => _items.Length;\n\n    /// <summary>\n    /// Whether or not the buffer is at capacity.\n    /// </summary>\n    public bool IsFull => Count == Capacity;\n\n    /// <summary>\n    /// Access an item in the buffer. Indexing is based off\n    /// of the order items were added, rather than any\n    /// internal ordering the buffer may be maintaining.\n    /// </summary>\n    /// <param name=\"index\">The index of the item to access.</param>\n    /// <returns>The buffered item at index <paramref name=\"index\" />.</returns>\n    public T this[int index]\n    {\n        get\n        {\n            if (!(index >= 0 && index < Count)) throw new ArgumentOutOfRangeException(nameof(index));\n\n            return _items[WrapIndex(index)];\n        }\n    }\n\n    /// <summary>\n    /// Convert from a 0-based index to a buffer index which\n    /// has been properly offset and wrapped.\n    /// </summary>\n    /// <param name=\"zeroBasedIndex\">The index to wrap.</param>\n    /// <exception cref=\"ArgumentOutOfRangeException\">If <paramref name=\"zeroBasedIndex\" /> is out of range.</exception>\n    /// <returns>\n    /// The actual index that\n    /// <param ref=\"zeroBasedIndex\" />\n    /// maps to.\n    /// </returns>\n    private int WrapIndex(int zeroBasedIndex)\n    {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/dotnetcore/CAP/blob/e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb/src/DotNetCore.CAP.Dashboard/CircularBuffer.cs#L44-L80","documentation":"ArgumentOutOfRangeException thrown by the CircularBuffer indexer getter: the requested index is negative or >= Count, so WrapIndex cannot map it to a valid slot in the underlying array. The buffer is empty or smaller than the caller assumes.","triggerScenarios":"Thrown at src/DotNetCore.CAP.Dashboard/CircularBuffer.cs:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check Count (and Capacity) before indexing: if (i >= 0 && i < buffer.Count) ...","Use the fact that indexing is insertion-ordered; recompute indices after Add/Take operations since the window slides","Iterate with foreach (backed by GetEnumerator) instead of manual indexing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb","analyzedAt":"2026-09-14T14:46:34.677Z","contentChangedAt":"2026-09-14T14:46:34.677Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}