{"record":{"id":"3fed1f0a12ce63cb","repo":"QuantConnect/Lean","slug":"custom-data-was-not-fetched","errorCode":null,"errorMessage":"Custom data was not fetched","messagePattern":"Custom data was not fetched","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/DescendingCustomDataObjectStoreRegressionAlgorithm.cs","lineNumber":96,"sourceCode":"        public override void OnData(Slice slice)\n        {\n            if (slice.ContainsKey(_customSymbol))\n            {\n                var sortCustomData = slice.Get<SortCustomData>(_customSymbol);\n                if (sortCustomData.Open == 0 || sortCustomData.High == 0 || sortCustomData.Low == 0 || sortCustomData.Close == 0 || sortCustomData.Price == 0)\n                {\n                    throw new RegressionTestException(\"One or more custom data fields (Open, High, Low, Close, Price) are zero.\");\n                }\n\n                _receivedData.Add(sortCustomData);\n            }\n        }\n\n        public override void OnEndOfAlgorithm()\n        {\n            if (_receivedData.Count == 0)\n            {\n                throw new RegressionTestException(\"Custom data was not fetched\");\n            }\n\n            var history = History<SortCustomData>(_customSymbol, StartDate, EndDate, Resolution.Hour).ToList();\n\n            if (history.Count != _receivedData.Count)\n            {\n                throw new RegressionTestException(\"History request returned different data than expected\");\n            }\n\n            // Iterate through the history collection, checking if the EndTime is in ascending order.\n            for (int i = 0; i < history.Count - 1; i++)\n            {\n                if (history[i].EndTime > history[i + 1].EndTime)\n                {\n                    throw new RegressionTestException($\"Order failure: {history[i].EndTime} > {history[i + 1].EndTime} at index {i}.\");\n                }\n            }\n        }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/DescendingCustomDataObjectStoreRegressionAlgorithm.cs#L78-L114","documentation":"OnEndOfAlgorithm asserts _receivedData.Count > 0. _receivedData is populated in OnData only when slice.ContainsKey(_customSymbol) is true and the zero-field check passes. A count of 0 means no custom data point was ever delivered to OnData during the entire backtest.","triggerScenarios":"The SortCustomData subscription never produced a data point: ObjectStore.Save failed or was empty, the subscription symbol/key mismatch, GetSource returns an unreachable key, or the date range (2024-09-09 to 2024-10-03) has no matching rows after filtering.","commonSituations":"ObjectStore key in SortCustomData.CustomDataKey does not match the AddData symbol registration, the object store is not enabled/configured, or Reader returns null for every line so nothing reaches OnData.","solutions":["Confirm ObjectStore.Save(CustomDataKey, ...) succeeds in Initialize and the key matches SortCustomData.CustomDataKey used in GetSource.","Verify AddData<SortCustomData>(...) symbol and that _customSymbol matches the subscription.","Log inside SortCustomData.Reader to confirm it is invoked and returns non-null objects.","Check the date range aligns with the data timestamps (2024-09-09 to 2024-10-03)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// In Initialize, verify the object store save succeeded\nObjectStore.Save(CustomDataKey, string.Join(\"\\n\", descendingCustomData));\nif (!ObjectStore.ContainsKey(CustomDataKey))\n{\n    throw new InvalidOperationException(\"ObjectStore save failed; no custom data will be delivered\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify ObjectStore.Save succeeds and the key matches SortCustomData.CustomDataKey.","Log inside Reader to confirm it is invoked.","Confirm the date range overlaps the data timestamps."],"tags":["quantconnect","custom-data","object-store","subscription","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}