{"record":{"id":"411b543988c2b4b3","repo":"QuantConnect/Lean","slug":"call-should-have-returned-expected-type-expe","errorCode":null,"errorMessage":"{call} should have returned {expected} ({type(expected)}) but returned null","messagePattern":"(.+?) should have returned (.+?) \\((.+?)\\) but returned null","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/GetParameterRegressionAlgorithm.py","lineNumber":39,"sourceCode":"    def initialize(self):\n        self.set_start_date(2013, 10, 7)\n        self.check_parameter(None, self.get_parameter(\"non-existing\"), \"GetParameter(\\\"non-existing\\\")\")\n        self.check_parameter(\"100\", self.get_parameter(\"non-existing\", \"100\"), \"GetParameter(\\\"non-existing\\\", \\\"100\\\")\")\n        self.check_parameter(100, self.get_parameter(\"non-existing\", 100), \"GetParameter(\\\"non-existing\\\", 100)\")\n        self.check_parameter(100.0, self.get_parameter(\"non-existing\", 100.0), \"GetParameter(\\\"non-existing\\\", 100.0)\")\n\n        self.check_parameter(\"10\", self.get_parameter(\"ema-fast\"), \"GetParameter(\\\"ema-fast\\\")\")\n        self.check_parameter(10, self.get_parameter(\"ema-fast\", 100), \"GetParameter(\\\"ema-fast\\\", 100)\")\n        self.check_parameter(10.0, self.get_parameter(\"ema-fast\", 100.0), \"GetParameter(\\\"ema-fast\\\", 100.0)\")\n\n        self.quit()\n\n    def check_parameter(self, expected, actual, call):\n        if expected == None and actual != None:\n            raise AssertionError(f\"{call} should have returned null but returned {actual} ({type(actual)})\")\n\n        if expected != None and actual == None:\n            raise AssertionError(f\"{call} should have returned {expected} ({type(expected)}) but returned null\")\n\n        if expected != None and actual != None and type(expected) != type(actual) or expected != actual:\n            raise AssertionError(f\"{call} should have returned {expected} ({type(expected)}) but returned {actual} ({type(actual)})\")\n","sourceCodeStart":21,"sourceCodeEnd":43,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/GetParameterRegressionAlgorithm.py#L21-L43","documentation":"Same check_parameter helper, expected-not-null branch (lines 38-39). It asserts that get_parameter returns a value (either the configured value or the supplied default) instead of None. A None return here means parameter lookup stopped applying defaults or stopped reading existing keys like 'ema-fast'.","triggerScenarios":"self.get_parameter(\"ema-fast\") or self.get_parameter(\"non-existing\", <default>) returns None. expected is non-None (the configured '10' / default), actual is None, so line 38-39 raises.","commonSituations":"The 'ema-fast' parameter was removed from the regression config; GetParameter default-argument overload regressed to always return null; parameters dictionary failed to load from the job/config.","solutions":["Verify the regression parameter config still defines ema-fast=10 (check Launcher/config and the regression test parameters).","Inspect GetParameter(name, defaultValue) overloads: when key is absent the default must be returned (coerced to the requested type), not null.","Confirm the algorithm receives its parameters dictionary during initialize (IAlgorithm.SetParameters / job parameters wiring)."],"exampleFix":"// before: default overload returns null\npublic int GetParameter(string name, int defaultValue) => null;\n// after: return default when key missing\npublic int GetParameter(string name, int defaultValue)\n    => _parameters.TryGetValue(name, out var v) && int.TryParse(v, out var i) ? i : defaultValue;","handlingStrategy":"validation","validationCode":"# ensure a value or default before use\nema = self.get_parameter(\"ema-fast\", 10)\nif ema is None:\n    raise RuntimeError(\"ema-fast parameter missing and no default applied\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply a default to get_parameter when the value is required.","Validate required parameters at the start of initialize and fail loudly.","Document expected parameter keys in the algorithm summary."],"tags":["quantconnect","lean","regression","parameters","get-parameter","defaults"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}