{"record":{"id":"35008de0f469bb90","repo":"dotnet/machinelearning","slug":"offsetbuffer","errorCode":null,"errorMessage":"offsetBuffer","messagePattern":"offsetBuffer","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs","lineNumber":54,"sourceCode":"        }\n\n        /// <summary>\n        /// Constructs an <see cref=\"ArrowStringDataFrameColumn\"/> with the given <paramref name=\"name\"/>, <paramref name=\"length\"/> and <paramref name=\"nullCount\"/>. The <paramref name=\"values\"/>, <paramref name=\"offsets\"/> and <paramref name=\"nullBits\"/> are the contents of the column in the Arrow format.\n        /// </summary>\n        /// <param name=\"name\">The name of the column.</param>\n        /// <param name=\"values\">The Arrow formatted string values in this column.</param>\n        /// <param name=\"offsets\">The Arrow formatted offsets in this column.</param>\n        /// <param name=\"nullBits\">The Arrow formatted null bits in this column.</param>\n        /// <param name=\"length\">The length of the column.</param>\n        /// <param name=\"nullCount\">The number of <see langword=\"null\" /> values in this column.</param>\n        public ArrowStringDataFrameColumn(string name, ReadOnlyMemory<byte> values, ReadOnlyMemory<byte> offsets, ReadOnlyMemory<byte> nullBits, int length, int nullCount) : base(name, length, typeof(string))\n        {\n            ReadOnlyDataFrameBuffer<byte> dataBuffer = new ReadOnlyDataFrameBuffer<byte>(values, values.Length);\n            ReadOnlyDataFrameBuffer<int> offsetBuffer = new ReadOnlyDataFrameBuffer<int>(offsets, length + 1);\n            ReadOnlyDataFrameBuffer<byte> nullBitMapBuffer = new ReadOnlyDataFrameBuffer<byte>(nullBits, nullBits.Length);\n\n            if (length + 1 != offsetBuffer.Length)\n                throw new ArgumentException(nameof(offsetBuffer));\n\n            _dataBuffers = new List<ReadOnlyDataFrameBuffer<byte>>();\n            _offsetsBuffers = new List<ReadOnlyDataFrameBuffer<int>>();\n            _nullBitMapBuffers = new List<ReadOnlyDataFrameBuffer<byte>>();\n\n            _dataBuffers.Add(dataBuffer);\n            _offsetsBuffers.Add(offsetBuffer);\n            _nullBitMapBuffers.Add(nullBitMapBuffer);\n\n            _nullCount = nullCount;\n        }\n\n        private long _nullCount;\n\n        /// <inheritdoc/>\n        public override long NullCount => _nullCount;\n\n        /// <inheritdoc/>","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs#L36-L72","documentation":"The ArrowStringDataFrameColumn constructor validates that the offsets buffer contains exactly length + 1 entries (Arrow string-array layout requires one offset per value plus a final terminating offset). When offsets.Length != length + 1, it throws ArgumentException(nameof(offsetBuffer)), i.e. an exception whose message is the parameter name.","triggerScenarios":"new ArrowStringDataFrameColumn(name, dataBuffer: values, offsets, nullBits, length) where the offsets array length is not exactly length + 1 (e.g. passing offsets for a different number of strings, or an off-by-one where the final terminating offset was omitted).","commonSituations":"Hand-building Arrow-format buffers from another format (IPC file, Parquet decode, custom serialization) with inconsistent metadata; forgetting the +1 terminating offset; using length = number of offset bytes instead of number of strings.","solutions":["Ensure offsets.Length == length + 1 before constructing; recompute length from offsets as offsets.Length - 1.","Verify the offsets array includes the final terminating offset equal to values.Length.","Check that the buffer/byte arrays were sliced with the correct end indices when extracting from an Arrow IPC stream.","Assert consistency: values.Length must equal offsets[length]."],"exampleFix":"// before\nvar col = new ArrowStringDataFrameColumn(\"s\", values, offsets, nullBits, offsets.Length); // wrong length\n\n// after\nlong length = offsets.Length - 1;\nvar col = new ArrowStringDataFrameColumn(\"s\", values, offsets, nullBits, length); // offsets.Length == length + 1","handlingStrategy":"validation","validationCode":"if (offsets.Length != length + 1)\n    throw new ArgumentException($\"offsets must have length + 1 = {length + 1} entries, got {offsets.Length}\");","typeGuard":null,"tryCatchPattern":"try { new ArrowStringDataFrameColumn(name, values, offsets, nullBits, length); }\ncatch (ArgumentException) { /* re-derive length = offsets.Length - 1 and retry */ }","preventionTips":["Always derive length as offsets.Length - 1","Include the terminating offset in Arrow string arrays","Assert offsets[length] == values.Length before constructing","Validate buffer slices extracted from IPC streams"],"tags":["dotnet","arrow","dataframe","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}