{"record":{"id":"9f472ef806245abf","repo":"QuantConnect/Lean","slug":"unexpected-universe-data-receieved","errorCode":null,"errorMessage":"Unexpected universe data receieved","messagePattern":"Unexpected universe data receieved","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/DropboxBaseDataUniverseSelectionAlgorithm.cs","lineNumber":71,"sourceCode":"            SetEndDate(2018, 07, 04);\n\n            var universe = AddUniverse<StockDataSource>(stockDataSource =>\n            {\n                return stockDataSource.OfType<StockDataSource>().SelectMany(x => x.Symbols);\n            });\n\n            var historicalSelectionData = History(universe, 3).ToList();\n            if (historicalSelectionData.Count != 3)\n            {\n                throw new RegressionTestException($\"Unexpected universe data count {historicalSelectionData.Count}\");\n            }\n\n            foreach (var universeData in historicalSelectionData)\n            {\n                var stockDataSource = (StockDataSource)universeData.Single();\n                if (stockDataSource.Symbols.Count != 5)\n                {\n                    throw new RegressionTestException($\"Unexpected universe data receieved\");\n                }\n            }\n        }\n\n        /// <summary>\n        /// Event - v3.0 DATA EVENT HANDLER: (Pattern) Basic template for user to override for receiving all subscription data in a single event\n        /// </summary>\n        /// <code>\n        /// TradeBars bars = slice.Bars;\n        /// Ticks ticks = slice.Ticks;\n        /// TradeBar spy = slice[\"SPY\"];\n        /// List{Tick} aaplTicks = slice[\"AAPL\"]\n        /// Quandl oil = slice[\"OIL\"]\n        /// dynamic anySymbol = slice[symbol];\n        /// DataDictionary{Quandl} allQuandlData = slice.Get{Quand}\n        /// Quandl oil = slice.Get{Quandl}(\"OIL\")\n        /// </code>\n        /// <param name=\"slice\">The current slice of data keyed by symbol string</param>","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/DropboxBaseDataUniverseSelectionAlgorithm.cs#L53-L89","documentation":"For each of the 3 universe-history rows, the algorithm casts the single entry to StockDataSource and asserts its Symbols list has exactly 5 entries. A failure means a row in the Dropbox CSV has fewer or more than 5 symbol columns, or Reader mis-parsed the line.","triggerScenarios":"A CSV row in daily-stock-picker-backtest.csv has !=5 symbols after the date column, or the live/backtest format branch in Reader (which uses csv.Skip(1)) includes/excludes an unexpected column.","commonSituations":"The Dropbox CSV format changed (added/removed a symbol column), a trailing comma creating an empty extra symbol, or the isLiveMode branch being taken unexpectedly.","solutions":["Download the CSV and verify every row has exactly 5 symbol columns after the date.","Log csv.Count inside Reader to catch trailing-comma or short-row issues.","Filter empty strings from csv.Skip(1) before AddRange to handle trailing commas.","Pin the CSV to a known-good version or vendor it locally for the regression."],"exampleFix":"// before\nstocks.Symbols.AddRange(csv.Skip(1));\n\n// after — filter empties from trailing commas\nstocks.Symbols.AddRange(csv.Skip(1).Where(s => !string.IsNullOrWhiteSpace(s)));","handlingStrategy":"validation","validationCode":"public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)\n{\n    var csv = line.ToCsv();\n    var stocks = new StockDataSource { Symbol = config.Symbol };\n    stocks.Time = DateTime.ParseExact(csv[0], \"yyyyMMdd\", null);\n    stocks.Symbols.AddRange(csv.Skip(1).Where(s => !string.IsNullOrWhiteSpace(s)));\n    if (stocks.Symbols.Count != 5)\n        Debug($\"Row has {stocks.Symbols.Count} symbols, expected 5: {line}\");\n    return stocks;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter empty CSV fields to handle trailing commas.","Validate the symbol count per row in Reader and log discrepancies.","Pin the CSV format or vendor it locally to prevent external format drift."],"tags":["quantconnect","universe-selection","custom-data","csv-parsing","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}