{"record":{"id":"83d6efd624349edd","repo":"ytdl-org/youtube-dl","slug":"traceback-format-exc-dynamic-surfaces-in-unab","errorCode":null,"errorMessage":"traceback.format_exc() (dynamic; surfaces in 'Unable to decode n-parameter' warning)","messagePattern":"traceback\\.format_exc\\(\\) \\(dynamic; surfaces in 'Unable to decode n-parameter' warning\\)","errorType":"exception","errorClass":"JSInterpreter.Exception","httpStatus":null,"severity":"warning","filePath":"youtube_dl/extractor/youtube.py","lineNumber":2120,"sourceCode":"\n    def _extract_n_function_code_jsi(self, video_id, jsi, player_id=None, player_url=None):\n        func_name = self._extract_n_function_name(jsi.code)\n\n        func_code = self._extract_sig_fn(jsi, func_name)\n        if player_url:\n            self._store_player_data_to_cache('nsig', player_url, func_code)\n        return jsi, player_id, func_code\n\n    def _extract_n_function_from_code(self, jsi, func_code):\n        func = jsi.extract_function_from_code(*func_code)\n\n        def extract_nsig(s):\n            try:\n                ret = func([s], kwargs={'_ytdl_do_not_return': s})\n            except JSInterpreter.Exception:\n                raise\n            except Exception as e:\n                raise JSInterpreter.Exception(traceback.format_exc(), cause=e)\n\n            if ret.startswith('enhanced_except_') or ret.endswith(s):\n                raise JSInterpreter.Exception('Signature function returned an exception')\n            return ret\n\n        return extract_nsig\n\n    def _unthrottle_format_urls(self, video_id, player_url, *formats):\n\n        def decrypt_nsig(n):\n            return self._cached(self._decrypt_nsig, 'nsig', n, player_url)\n\n        for fmt in formats:\n            n_param = parse_qs(fmt['url']).get('n')\n            if not n_param:\n                continue\n            n_param = n_param[-1]\n            n_response = decrypt_nsig(n_param)(n_param, video_id, player_url)","sourceCodeStart":2102,"sourceCodeEnd":2138,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/youtube.py#L2102-L2138","documentation":"Not a standalone raise: inside extract_nsig (built by _extract_n_function_from_code) any non-JSInterpreter exception from executing the extracted JS function is re-raised as JSInterpreter.Exception(traceback.format_exc(), cause=e). The full Python traceback string becomes the exception message, which later surfaces in the 'Unable to decode n-parameter: expect download to be blocked or throttled' warning emitted by _decrypt_nsig's handler.","triggerScenarios":"Executing the extracted nsig JS function raises an unexpected Python error (type error, key error in the JS interpreter, etc.) for some input n values — e.g. interpreter gaps hitting new JS syntax, or a function that behaves differently for edge-case signatures.","commonSituations":"A new player version uses JS features the bundled interpreter mishandles; only some n values hit the failing branch, so most downloads work but occasional ones warn; stale cached nsig functions being reused against a new player.","solutions":["Update youtube-dl/yt-dlp so both the extraction pattern and JS interpreter handle the current player.","Read the embedded traceback text in the warning — it names the actual Python error inside the interpreter and points at the unsupported operation.","Clear the cached player/nsig data (cache dir) so a fresh function is extracted after updating.","If downloads only become slow (not broken), the warning can be tolerated while awaiting an upstream fix."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    ret = extract_nsig(n)\nexcept JSInterpreter.Exception as e:\n    # message contains a full Python traceback; log for diagnosis, keep throttled URL\n    log_warning('Unable to decode n-parameter: %s' % str(e).splitlines()[-1])\n    return None  # caller falls back to the un-decrypted URL","preventionTips":["Parse only the last traceback line for the actionable error; the rest is interpreter internals.","Clear the player/nsig cache after updating so stale functions do not keep failing."],"tags":["youtube","nsig","js-interpreter","dynamic-message"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}